× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Pete,

When I'm stuck using SQL for stuff like that, I do the following... this works fine for me.  The only caveat is you must have your job CCSID set properly.  (It won't work with 65535)

dcl-s request  varchar(2000);

exec sql select json_object(
                  'source' value :fromLang,
                  'target' value :toLang,
                  'text' value json_array(:fromText)
                )
           into :request
           from SYSIBM.SYSDUMMY1;

On 5/21/2021 5:53 PM, Pete Helgren wrote:
Posted to Midrange by habit.....sorry for the duplicate...


I have an sqlrpgle program that creates JSON output using JSON_ARRAY (among others) and outputs JSON (actually, SQL is pretty cool along these lines).  Running just the SQL statement interactively, I get just what I expect, nicely formatted JSON. When I run it within the RPG program, I have some issues.  It really boils down to understanding a couple of things:

If the goal is to output the SQL into a variable and then dump that variable out using Standard Out (QtmhWrStout) what should the variable type be?  Originally I tried varchar but I got an error when it was output due to "reason code 12:   -- The CCSIDs (Coded Character Set Identifiers) of the operands cannot be made compatible."   So either I chose the wrong data type or I need to set a CCSID.  I tripped across a post from a few years ago that using a DBCLOB or a CLOB type an CCSID of 1200.  I do get output now (no error) but it is just a string of '@@@@@@@@@@@@@@@@...'s that tells me a have CCSID issue.

Tried a few other ideas, still get the wrong output.  So the question is:  If the plan is to output through a CGI pgm using QtmhWrStout how should I define the variable and should it be assigned a CCSID?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.