how to insert a Jsonarray that select from a table filed(Jsonarray type) to other table field (also jsonarray type)
-
I use queryCdby.prepare("select * from TankCapacityOld WHERE ZCertNo=:FCertNo"); to get a JSonarray filed from table TankCapcityOld.
and i want insert to other table by :
queryCdbN.prepare("replace INTO TankCapacity2(ZCertNo,ZCertNoOffical,TankNames) VALUES (:ZCertNo,:ZCertNoOffical,CONVERT(:TankNames USING UTF8MB4));
queryCdbN.bindValue(":TankNames",QJsonDocument(queryCdby.value("TankNames").toJsonArray()));But the TankNames filed is null in table TankCapacity2.
i use: qDebug()<<queryCdby.value("TankNames").toJsonArray()<<QJsonDocument(queryCdby.value("TankNames").toJsonArray())<<queryCdby.value("TankNames");
got :
QJsonArray() QJsonDocument([]) QVariant(QByteArray, "[\n "P1",\n "S1",\n "P2",\n "S2",\n "P3",\n "S3",\n "P4",\n "S4",\n "PS",\n "SS"\n]\n")how to insert the Jsonarray filed from a table to other table ?
(queryCdby and queryCdbN are for different database ) -
Hi,
You should start by ensuring that you are getting the data you want from the first query.
-
Hi,
You should start by ensuring that you are getting the data you want from the first query.
-
From the looks of it, you should turn back array to a QByteArray before writing it to your other database.