|
Am 03.02.2022 um 19:13 schrieb Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx>:
Define an Array with NULL indicators (Int(5)) one element per column.
Initialize your output Data Structure before reading the data into the
data structure. If NULL values are passed, the appropriate Indicator
in the indicator array is set to -1, but the Output Fields are not changed.
So if you had initialized the data structure before, the
Data-Structure Sub-Fields have the default values.
Example:
DCL-DS YourOutputDS ...
End-DS;
DCL-S YourOutputInd Int(5) Dim(NbrOfDSSubfields);
Clear YourOutPutDS;
Clear YourOutputInd;
Exec SQL Fetch Next From YourCsr
Into :YourOutputDS :yourOutputInd; // Attention no Comma
between DS and Indicator Array!!!
//Check SQLCODE or SQLSTATE
//You may check if a NULL value is returned If YourOutputInd(1) = -1;
//Null Value in the first column.
BTW it is also possible to update or insert a complete row.
If a NULL value has to be written the appropriate Indicator has to be
set to -1.
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 <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
dfreinkel@xxxxxxxxxxxxxxxxx
Sent: Donnerstag, 3. Februar 2022 19:00
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Reading using SQL and dealing with nulls
I am reading a system view in RPG.
Some of the fields have nulls.
I do not want to recode the data structure to ignore these fields as I
may need them.
Is there a way to tell the compiler to initialize these fields?
TIA
Darryl Freinkel
A4G
Telephone: 770.321.8562 Mobile: 678.355.8562
--
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
--
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.
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.