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



No it can't you have to convert each column.
That's why I suggested using the Indicator Array.

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 20:08
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Reading using SQL and dealing with nulls

Thank you.

Can the field be a data structure?

Darryl Freinkel
A4G
Telephone: 770.321.8562 Mobile: 678.355.8562

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Daniel Gross
Sent: Thursday, February 3, 2022 1:23 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Reading using SQL and dealing with nulls

Alternatively to Birgittas suggestion, you can also fix the “null problem” with the use of a SQL function - like this:

exec sql select ifnull(field_name, ‘’),
…..
into :rpg_field
from …..;

With ifnull(), nvl() or coalesce() you can “replace” Null values with another value, so that you don’t need to code null indicators.

HTH
Daniel


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

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