|
Hi ArtFETCH.
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
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 SQL0029wrote:
"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>
midrange-l@xxxxxxxxxxxxxxxxxx>
...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 <
mySubject: 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
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2FlistSTMF 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:
s.midrange.com%2Fmailman%2Flistinfo%2Fmidrange-l&data=02%7C01%7C%7
C984eb1e52e564c1e8c1308d79f583140%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7
C1%7C0%7C637153073435789651&sdata=672pPpN5I%2BGatxCcSFK5NRc5xBaEzx
Z3sy4uzr8vCVs%3D&reserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchor email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
ive.midrange.com%2Fmidrange-l&data=02%7C01%7C%7C984eb1e52e564c1e8c
1308d79f583140%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C6371530734
35789651&sdata=3TKI3aTa1nR3pQFUA4CRPiT9Yv%2FmtGePBcWtz7%2Bb7RI%3D&
amp;reserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Famaz.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link:
on.midrange.com&data=02%7C01%7C%7C984eb1e52e564c1e8c1308d79f583140
%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637153073435789651&s
data=ybPbtD06UhXYWmjBNE%2FAKxlXDV9%2BIL9v6ZrDdM0NYAc%3D&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://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our
affiliate
link: https://amazon.midrange.com
--
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://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
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.