1

I try to make a JSON_OBJECT in my SQLRPGLE Program. But even the simplest doesnt work:

**FREE
ctl-opt dftactgrp(*no) actgrp(*caller);
dcl-s  PAYLOAD     varchar(1000);
 EXEC SQL
          SELECT CAST(
                   JSON_OBJECT(
                    'Test' value 'hello'
            ) AS CLOB(1000000))
    INTO :PAYLOAD
FROM SYSIBM.SYSDUMMY1;
*inlr = *on;
return;  

I always get SQLSTATE 57017 and SQLCODE -332. Character conversion is not defined. The Machine is a 7.3 and my job ccsid is 1141. I also tried to make the payload as an sqltype:

dcl-s  PAYLOAD     SQLTYPE(CLOB:1000000) CCSID(1208) INZ;

but nothing works. Does anyone have a solution? Thanks.

1 Answer 1

0

I was able to find out what the problem was.
The PF-SRC file had the CCSID 65535, which changes all the Characters in the SQL function and make them unconversionable. It compiles, but it will give back an SQLSTATE of failing.
The workaround, if you cant make a new PF-SRC, you have to use only variables in the SQL function.

dcl-s  Test     char(4) inz('Test');
dcl-s  hello    char(5) inz('hello');
dcl-s  PAYLOAD  varchar(1000);
 EXEC SQL
          SELECT CAST(
                   JSON_OBJECT(
                    :Test value :hello
            ) AS CLOB(1000000))
    INTO :PAYLOAD
FROM SYSIBM.SYSDUMMY1;
*inlr = *on;
return;  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.