Birgitta,
Thanks... that is essentially what I did.
I suppose it's more efficient to select 3 separate fields than to concatenate?
In my programs that access this data, some simply need each of the 40 character fields. However, others need the 40 character data into subfields (data structure) as below.
I have this situation as well.
dcl-ds myDS qualified inz;
lines char(120) pos(1);
row dim(3) pos(1);
subfield1 char(15) overlay(row:1);
subfield2 char(15) overlay(row:*next);
subfield3 char(5) overlay(row:*next);
subfield4 char(5) overlay(row:*next);
end-ds;
Exec SQL
Select Field1 || Field2 || Field 3 into :myDS.lines
From TABLE
Where ...
Thx,
Greg
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Birgitta Hauser
Sent: Thursday, September 8, 2022 1:39 PM
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Select Into
What if you create your Data Structure as follows:
dcl-ds myDS qualified Inz;
myFld1 char(40);
myFld2 Char(40);
myFld3 Char(40);
myArray char(40) dim(3) pos(1);
end-ds;
And your SELECT ... INTO Statement as follows:
Exec SQL
Select Field1, Field2, Field 3 into :myDS
From TABLE
Where ...
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
Modernization - Education - Consulting on IBM i
"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@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg
Wilburn
Sent: Donnerstag, 8. September 2022 19:14
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Select Into
Selecting one row only, 3 fields. I just need the 3 fields in an array.
Compiler fails if the "into" variable is a dimensioned array.
Variable MYARRAY not defined or not usable. Reason: The variable is a
dimensioned array.
BTW - there are ways around using a cursor when more than one row is
selected.
https://www.itjungle.com/2021/03/08/guru-select-into-and-arrays/
What I had in my original post works... I just wondered if there was a
better way of defining my into variable.
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Charles
Wilt
Sent: Thursday, September 8, 2022 12:20 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Select Into
SELECT INTO only works for single row result sets...
Does your SQL statement return only a single row?
What error message (and when) are you getting?
Charles
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx 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.