B
bkozak
Guest
We have an application that stores serialized JSON into our DB as a blob. BUFFER tt{&Table}:HANDLE:SERIALIZE-ROW('JSON','LONGCHAR',lcRecord,NO,'UTF-8',TRUE,TRUE). COPY-LOB FROM lcRecord TO We then read this data back into a logging application, and one of the functions we're trying to do is restore deleted records. So we grab that blobfield back out of the DB and so something like this: DEF VAR lcJson as LONGCHAR NO-UNDO. oJson = NEW JsonObject(). oJsonParser = NEW ObjectModelParser(). lcJson = ?. FIX-CODEPAGE(lcJson) = 'UTF-8'. COPY-LOB FROM TO lcJson. oJson = CAST(oJsonParserarse(lcJson), JsonObject). CREATE TEMP-TABLE hTempTable. hTempTable:READ-JSON("JsonObject", oJson, "EMPTY"). hTTdefault = hTempTableEFAULT-BUFFER-HANDLE. CREATE QUERY hQuery. hQuery:SET-BUFFERS(hTTdefault). hQuery:QUERY-PREPARE('for each ' + hTempTable:NAME). hQuery:QUERY-OPEN(). hQuery:GET-FIRST(). DO TRANSACTION: CREATE BUFFER hBuffer FOR TABLE ttDatasetLog.tablename. hbuffer:BUFFER-CREATE(). hbuffer:BUFFER-COPY(hTTdefault). END. The record gets restored to the DB just fine, but for some reason that escapes me integer and date fields aren't restored properly. They are 0 / ?. Decimals, characters, logicals all seem to be ok. Was wondering if anyone's come across this before, and what they did to fix it? TIA, Brad
Continue reading...
Continue reading...