× 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 Vicki,

Its not clear from your post whether the varchar is working for you, or whether it's even needed?  If you want to look into the varchar situation further, please post a code sample so I can understand what you are doing.  I will admit, it can be a bit tricky to convert to varchar due to the fact that yajl_copyBuf() uses pointers rather than strings...  but it's possible.  Just let me know.  (Or, use yajl_copyBufStr() instead.)

With regards to a CLOB, its pretty easy. As Birgitta explained, the SQLTYPE CLOB will generate a data structure with separate fields called xxx_DATA and xxx_LEN. The DATA field is a 'char' field, and importantly, the LEN field is unsigned (so uns(10) in RPG.) The only tricky part of that is that yajl_copyBuf() expects a signed integer rather than unsigned, so you need to use a temporary variable.

With that in mind, the logic looks like this:

       dcl-s myClob SQLTYPE(CLOB:256000);
       dcl-s len int(10);

yajl_genOpen(*on);

       ... your logic to generate your JSON document goes here ...

       yajl_copyBuf( 0
                   : %addr(myClob_DATA)
                   : %size(myClob_DATA)
                   : len );

       myClob_LEN = len;
       yajl_genClose();

Then, of course, you'd use SQL to insert or update the CLOB field.


On 6/27/2018 6:12 PM, Vicki Wilson wrote:
Hi all,

Working on first YAJL - proof of concept program - we are on v7r1 (v7r2 not an option right now.)

I have successfully written to the IFS using the yajl_saveBuf function to verify I'm creating the JSON correctly.
Instead of writing to the IFS I would like to write it to a CLOB field in the database. Here's where I'm stumbling.

I have defined a varchar of 256000 in the program. I tried to yajl_copyBuf to retrieve the data into the varchar field. I'm not sure I succeeded. I'm not used to working with such large varchar fields. Can I see it when I debug? - It has something in it - just not sure what.

So here's where it gets murkier. Can I insert a varchar into and SQL clob? Or do I need to move the varchar into an SQLCLOB first and then insert? And/or can I use the yajl_copyBuf to retrieve into the sql type of clob and then insert into the database.

Examples and references would be great.

Thanks.
Vicki Wilson




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.