× 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.



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.
Since SQL does not support varchar fields greater than 32K, you need to move
the VarChar data first into a CLOB Variable before it is inserted into a
CLOB column.

DCL-S YourVarChar VarChar(256000);
DCL-S YourCLOB SQLTYPE(CLOB: 256000);

YourClob_Data = %Trim(YourVarChar);
YourClob_Len = %Len(%Trim(YourVarChar);

Exec SQL Insert into YourTable (..., YourClobCol, ...)
Values(..., :YourClob, ...);

I haven't tried it, but since a CLOB variable is converted into a data
structure and you can access the data structure subfields directly in RPG.
It should be possible to retrieve the YAJL data directly into the _DATA
subfield of a CLOB variable.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxx> On Behalf Of Vicki Wilson
Sent: Donnerstag, 28. Juni 2018 01:12
To: rpg400-l@xxxxxxxxxxxx
Subject: YAJL - VARCHAR - CLOB question

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


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD


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.