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.