Hi All
Here is where I am at. The ResponseFile is the path to the json.
dcl-s db64 sqltype(clob:180000);
dcl-s pdf sqltype(clob:180000);
Dcl-S DecodedReportBinary SQLType(VarBinary : 32740);
Dcl-S DecodedReport VarChar(16000) CCSID(1208);
exec sql SET OPTION COMMIT = *CS, NAMING = *SYS, CLOSQLCSR = *ENDMOD;
exec sql set :db64 =
get_clob_from_file(:ResponseFile,0);
exec sql commit;
exec sql set :pdf = json_query(:db64,'$.summarypdfb64' omit quotes);
Clear DecodedReportBinary;
Exec SQL Values QSYS2.BASE64_DECODE(:PDF)
Into :DecodedReportBinary;
DecodedReport = DecodedReportBinary;
The SQLState is 01004, right truncation.
I just have never had to deal with variable this long.
What am I doing wrong???
The pdf variable contains the base 64 field from the json.
I am finding so little documentation on the qsys2.base64_decode!
Can the qsys2.base64_decode accept a clob as the input string?
If not, how do I convert clob to blob or varchar?
Is what I am trying to do so unique that I am not finding documentation? I wouldn't think so.
I am getting feedback from people that the decode routines can't do more that 4096 at a time and I have to decode in chunks?
Is that right?
I feel I am so close!!
This is what is working on a much small object. DecodedLabel contains the ZPL code.
// Label Response From API Call
Dcl-ds LabelResponse Qualified;
success Ind;
warning Ind;
cnt_messages Int(5);
ApiReference1 VarChar(100);
ApiReference2 VarChar(100);
ApiReference3 VarChar(100);
ApiReference4 VarChar(100);
messages VarChar(100) Dim(10);
labeltype Char(10);
base64data VarChar(4096) CCSID(1208);
End-Ds;
Dcl-S DecodedLabelBinary SQLType(VARBINARY:4096);
Dcl-S DecodedLabel VarChar(4096) CCSID(1208);
Clear DecodedReportBinary;
Exec SQL Values QSYS2.BASE64_DECODE(:Labelresponse.base64data) Into :DecodedLabelBinary;
Into :DecodedReportBinary;
DecodedLabel = DecodedLabelBinary;
------------------------------
Jerry Forss
------------------------------