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

SET is the SQL Equivalent for the RPG EVAL.
HTTPGETClob is for to read information from an RESTful WebService.
If you want to read from the IFS, you need a different strategie, i.e. you need to define a LOB-File (DBCLOB, CLOB, BLOB or XML_CLOB, XML_DBCLOB, XML_BLOB) Variable.
The LOB-Variable is converted by the SQL Precompiler into a data structure with the sub-fields with the following suffixes:
_NL - Name length
_DL - Data lenth
_FO - File Operation (can be SQFRD - Read Only, SQFCRT - Create if not exists / Error if exists, SQFOVR - Create if not exists / Replace if exists, SQFAPP - Create if not exists, append if exists)
_NAME - IFS-File Name

LOB-Files can be handled with SQL function and commands like any character field.

Example for reading some information from a text file located in the IFS

DCL-S MyIFSFile SQLTYPE(CLOB_File);
DCL-S MyText VarChar(256);

MyIFSFile_Name = '/home/whateverDir/WhateverFile.txt';
MyIFSFile_NL = %Len(%Trim(MyIFSFile_Name));
MyIFSFile_FO = SQFRD;

Exec SQL Set :MyText = Substr(:MyIFSFile, 50, 100);

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 [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Booth Martin
Sent: Dienstag, 22. August 2017 00:08
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: RPG, retrieving JSON data from a web service

I have no idea what this all means, nor any idea where to go to find out.

Exec SQL
Set :JSONVar =
SysTools.httpgetCLOB('/home/bmartin/Louie.json', '');

SQL5016: Position 15 Qualified object name HTTPGETCLOB not valid.
Cause . . . . . : One of the following has occurred:
-- The syntax used for the qualified object name is not valid for the naming option specified. With system naming, the qualified form of an object name is schema-name/object-name. With SQL naming the qualified form of an object name is authorization-name.object-name.
-- The syntax used for the qualified object name is not allowed.
User-defined types cannot be qualified with the schema in the system naming convention on parameters and SQL variables of an SQL procedure or function.
Recovery . . . : Do one of the following and try the request again:
-- If you want to use the SQL naming convention, verify the SQL naming option in the appropriate SQL command and qualify the object names in the form authorization-id.object-name.
-- If you want to use the system naming convention, specify the system naming option in the appropriate SQL command and qualify the object names in the form schema-name/object-name.
-- With the system naming convention, ensure the user-defined types specified for parameters and variables in an SQL routine can be found in the current path.


On 8/21/2017 12:59 AM, Birgitta Hauser wrote:
I did not follow the complete thread,
but ... if he only wants to read data returned from a webservice, why
not just using embedded SQL?
Something like this:

DCL-S JSONVar SQLType(CLOB: 16000000);
DCL-S Text Char(50);

//--------------------------------------------------------------------
------
-------------------
Exec SQL
Set :JSONVar = SysTools.httpgetCLOB('http://YourURL', '');
Text = JSONVar_Data;
Dsply Text;

*InLR = *On;

JSONVar is converted by the SQL Precompiler into a data Structure with
2 Subfields JSONVAR_LEN as UNS(10) representing the data length
JSCONVAR_DATA as Char(specified CLOB Length) which includes the data

As soon as the data is read into a variable it can be used in
composition with the XML functions or YAJL like any other variable.
BTW Embedded SQL also allows data to be directly read from the IFS.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

--
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: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://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.