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



...maybe you'll find the example code here useful, I knocked it up to answer another question somewhere.

https://github.com/fathert/json-rpg-example

Tim.
________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Art Tostaine, Jr. <atostaine@xxxxxxxxx>
Sent: 22 January 2020 22:24
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: JSON Fetch First Row Only

Ah right. Thank you.

So I have this. How do I specify the json_object within the Fetch next
loop? I don't think I can use SELECT again?

exec sql select json_object('data':
json_arrayagg(
json_object(
'ExternalId': trim(:intermid),
'Prefix': trim(:PRFXDESC),
'FirstName': trim(:firstname),
'MiddleName': trim(:middlenme),
'LastName': trim(:lastname),
'Suffix': trim(:SUFFIXDES),
'dateofBirth': trim(:BIRTHDATE)
)
)
)
into :outFile;

I get this error:
SQL0104 Position 21 Token <END-OF-STATEMENT> was not valid. Valid tokens: ,
FROM.

Thanks, Art

On Wed, Jan 22, 2020 at 1:07 PM Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
wrote:

Hi Art

You cannot do a SELECT on its own like this - there are a couple things
- one is to DECLARE CURSOR with this statement, then do the OPEN and FETCH.

The precompiler thinks you are trying to do a SELECT INTO statement,
which does not need the DECLARE CURSOR.

Hope that makes a little sense.
Vern

On 1/22/2020 3:01 PM, Art Tostaine, Jr. wrote:
I've got this working in interactive SQL but I get SQL0029 SQL0029
"Position 13 INTO clause missing from embedded statement."
when trying to use in RPG. I don't know where it needs INTO. Some code
SNIPPED

With First_Row
(intermid,prfxdesc,firstname,middlenme,lastname,suffixdes,birthdate
)
AS (select
intermid,prfxdesc,firstname,middlenme,lastname,suffixdes,birthdate
from namintprp
fetch first 10 rows only
)

select json_object('data':
json_arrayagg(
json_object(
'ExternalId': trim(intermid),
'Prefix': trim(PRFXDESC),
'FirstName': trim(firstname),
'MiddleName': trim(middlenme),
'LastName': trim(lastname),
'Suffix': trim(SUFFIXDES),
'dateofBirth': trim(BIRTHDATE),
'dateofDeath': trim(DATEDEATH)
)
)
)
)
from First_Row;

On Wed, Jan 22, 2020 at 9:36 AM Art Tostaine, Jr. <atostaine@xxxxxxxxx>
wrote:

Thank you. I'll try to figure out how to use a CTE.

On Wed, Jan 22, 2020 at 8:35 AM Tim Fathers <X700-IX2J@xxxxxxxxxxx>
wrote:

...unfortunately not, as far as I can see. MariaDB allows the use of
OFFSET and LIMIT as part of the aggregation function but DB2 doesn't so
you'd need a sub-select or common table expression.

Tim.

________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of
Art Tostaine, Jr. <atostaine@xxxxxxxxx>
Sent: 22 January 2020 17:28
To: Midrange Systems Technical Discussion <
midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: JSON Fetch First Row Only

Can I use Fetch First Row Only in JSON_Object? This is a snip of the
code,
when I test the select in IBM iACS Sql scripts, I get one record. But
my
STMF from this statement has the JSON many times.


exec sql select json_object('data':
json_arrayagg(
json_object(
'ExternalId': trim(intermid),
'Prefix': trim(PRFXDESC),
'FirstName': trim(firstname),
.......
into :outFile
from namintprp
where nameid = '0275831'
fetch first row only
;

Thanks

--
Art Tostaine
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:

https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=3BxbVYtgD3aeVhXwD6GZnVLlwuDWs1r1rDcVrM8eHkQ%3D&amp;reserved=0
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at

https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=o4%2FdUSUokX9foPb9Gg%2BAM7kJ4yNShKV%2BR%2FSYtMK7diU%3D&amp;reserved=0
.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link:

https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=xc%2FtEbsNWTA5ajSqXMJU8WDVXocsOoyi1Nnov6KSatk%3D&amp;reserved=0
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=3BxbVYtgD3aeVhXwD6GZnVLlwuDWs1r1rDcVrM8eHkQ%3D&amp;reserved=0
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=o4%2FdUSUokX9foPb9Gg%2BAM7kJ4yNShKV%2BR%2FSYtMK7diU%3D&amp;reserved=0.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=xc%2FtEbsNWTA5ajSqXMJU8WDVXocsOoyi1Nnov6KSatk%3D&amp;reserved=0


--
Art Tostaine



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=3BxbVYtgD3aeVhXwD6GZnVLlwuDWs1r1rDcVrM8eHkQ%3D&amp;reserved=0
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=o4%2FdUSUokX9foPb9Gg%2BAM7kJ4yNShKV%2BR%2FSYtMK7diU%3D&amp;reserved=0.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=xc%2FtEbsNWTA5ajSqXMJU8WDVXocsOoyi1Nnov6KSatk%3D&amp;reserved=0



--
Art Tostaine
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=3BxbVYtgD3aeVhXwD6GZnVLlwuDWs1r1rDcVrM8eHkQ%3D&amp;reserved=0
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fmidrange-l&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=o4%2FdUSUokX9foPb9Gg%2BAM7kJ4yNShKV%2BR%2FSYtMK7diU%3D&amp;reserved=0.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Famazon.midrange.com&amp;data=02%7C01%7C%7Cfb6d744889f9458f392308d79f818d22%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153251068390397&amp;sdata=xc%2FtEbsNWTA5ajSqXMJU8WDVXocsOoyi1Nnov6KSatk%3D&amp;reserved=0

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.