Sweet! I've been able to get this to work using yajl_copyBufStr()!!
I would like to be able to use the yajl_copyBuf function.
When I change my code to use the yajl_copyBuf function. I receive the error below.
Any ideas on what may be causing this?
dcl-s JSONDataLength int(10);
dcl-c ToCCSID const(37);
dcl-s jsonData SQLTYPE(CLOB:2000000) inz;
%len(jsonData) = %len(jsonData:*max);
yajl_copyBuf( ToCCSID: %addr(jsonData: *Data): %len(jsonData): JSONDataLength);
%len(jsonData) = JSONDataLength;
Errors Messages
*RNF0229 20 1 *DATA is only valid for %ADDR when the definition is a
varying-length item; *DATA is ignored.
*RNF0235 20 1 *MAX is only valid for %LEN when the definition is a
varying-length item; *MAX is ignored.
Issue using yajl_saveBuf
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: Issue using yajl_saveBuf
Like the message says, you can only use *DATA and *MAX when working with a VARYING/VARCHAR variable.
Re: Issue using yajl_saveBuf
Thanks Scott! That worked!
Would you recommend doing anything different before I put clob data from buffer into the HTTP POST?
Program compiles correctly but I'm getting an SQL state of 01004 once it tries to POST data.
dcl-s JSONDataLength int(10);
dcl-c ToCCSID const(37);
dcl-s jsonData SQLTYPE(CLOB:1000000) inz;
dcl-s myUrl varchar(500);
dcl-s myhdr varchar(2000);
yajl_copyBuf( ToCCSID: %addr(jsonData):
%len(jsonData): JSONDataLength);
jsonData_Len = %len(%trimr(jsonData_data));
EXEC SQL
SELECT RESPONSE_MESSAGE, RESPONSE_HTTP_HEADER
INTO :rspData, :rspHdr
FROM TABLE(QSYS2.HTTP_POST_VERBOSE(
CAST(trim(:myUrl) AS VARCHAR(500)),
CAST(trim(:jsonData) AS CLOB(2G)),
CAST(trim(:myHdr) AS VARCHAR(2000))));
I appreciate all of your help!
Trent
Would you recommend doing anything different before I put clob data from buffer into the HTTP POST?
Program compiles correctly but I'm getting an SQL state of 01004 once it tries to POST data.
dcl-s JSONDataLength int(10);
dcl-c ToCCSID const(37);
dcl-s jsonData SQLTYPE(CLOB:1000000) inz;
dcl-s myUrl varchar(500);
dcl-s myhdr varchar(2000);
yajl_copyBuf( ToCCSID: %addr(jsonData):
%len(jsonData): JSONDataLength);
jsonData_Len = %len(%trimr(jsonData_data));
EXEC SQL
SELECT RESPONSE_MESSAGE, RESPONSE_HTTP_HEADER
INTO :rspData, :rspHdr
FROM TABLE(QSYS2.HTTP_POST_VERBOSE(
CAST(trim(:myUrl) AS VARCHAR(500)),
CAST(trim(:jsonData) AS CLOB(2G)),
CAST(trim(:myHdr) AS VARCHAR(2000))));
I appreciate all of your help!
Trent
Re: Issue using yajl_saveBuf
This is strange...
It's cutting off the first 4 characters from the front of the json when it copies data from buffer.
It should start like this.
{
"payorId": "company[09]",
It's cutting off the first 4 characters from the front of the json when it copies data from buffer.
It should start like this.
{
"payorId": "company[09]",
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: Issue using yajl_saveBuf
....because you're telling it the address of your data structure, instead of the address of the data subfield in your data structure...
%addr(jsonData_Data)
Please see the earlier message in this same thread where I explained to you how CLOB works.
%addr(jsonData_Data)
Please see the earlier message in this same thread where I explained to you how CLOB works.
Re: Issue using yajl_saveBuf
Thanks for all the help, Scott! I appreciate it!