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




...not the problem he was referring to below, as far as I could make out 🙂.

________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Jon Paris <jon.paris@xxxxxxxxxxxxxx>
Sent: 18 November 2019 17:28
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxxxxxxxx>
Subject: Re: [WEB400] json_table(httpgetclob, nested array

But he needs to imbed it in RPG Tim - and that is where his problem currently arises.


On Nov 18, 2019, at 3:54 AM, Tim Fathers <X700-IX2J@xxxxxxxxxxx> wrote:

Hi Booth,

This is the syntax you need:

select *

from json_table(
'{"wData_length":14,"SeasOceans":["Adriatic Sea","Arctic Ocean","Atlantic Ocean","Bay of Bengal","Caribbean Sea"]}',
'lax $'
columns(
DATA_LEN varchar(20) path '$.wData_length',
nested path '$.SeasOceans[*]'
columns(
SEA varchar(20) path '$'
)
)
) as U

...which gives...

DATA_LEN SEA
-------- --------------
14 Adriatic Sea
14 Arctic Ocean
14 Atlantic Ocean
14 Bay of Bengal
14 Caribbean Sea

As others have said, if you want to process the data row-by-row, you'll need to read it with a cursor but they are usually best avoided if you can, so if you need this data in a file just wrap the whole thing in an insert. Assuming the "wData_length" represents the length of the array then I think it's superfluous anyway, as you will only get back one row per array element so you don't need to care how many elements it's says there are..

Tim.

________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Booth Martin <booth@xxxxxxxxxxxx>
Sent: 18 November 2019 01:32
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxxxxxxxx>
Subject: Re: [WEB400] json_table(httpgetclob, nested array

exec sql select * into :wCount, :wSeas
from json_table(systools.httpgetclob(:wURL, ''), '$'
columns(
"wData_length" dec(3,0),
SeasOceans varchar(20) PATH 'lax $.SeasOceans[4]' ));

also works, in that it gives me the count and element[4].

For collecting an array, "nested" seems to be the correct word, probably
also needing ''lax $'. I suspect the issue involves either the SQLRPGLE
usage, or more likely, programmer error. I did try to loop. That gave
me element 1 repeatedly; I could not find a way to use a variable in
place of the $.SeasOcceans[4] and using an * instead of the 4 failed.


..On 11/17/2019 6:02 PM, Jon Paris wrote:
It is going to return a row for each element Booth so you'll probably need to use a cursor.

Does it work without nested?

--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213345142&amp;sdata=7pXJE6DgRm8uRA0h7Fh0z2F7e9%2BH3aTBz49XS7BvHq0%3D&amp;reserved=0
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213345142&amp;sdata=gL0wYV86Ml5rZV5nOwEsEK6DkVdeVUWgt8xTAoWIS1o%3D&amp;reserved=0.

--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213345142&amp;sdata=7pXJE6DgRm8uRA0h7Fh0z2F7e9%2BH3aTBz49XS7BvHq0%3D&amp;reserved=0
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213345142&amp;sdata=gL0wYV86Ml5rZV5nOwEsEK6DkVdeVUWgt8xTAoWIS1o%3D&amp;reserved=0.


--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213355191&amp;sdata=as6WZOhpVuH5vvbQExmc8J88TsILyD2MPZHYJI2wu7w%3D&amp;reserved=0
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&amp;data=02%7C01%7C%7C30491bddcf5c4f51343f08d76c445f11%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637096913213355191&amp;sdata=91B7MlTwwLwcW%2FC%2FJXDWnDbmaK7rBrP8E9D%2FNbzY8aU%3D&amp;reserved=0.


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.