Did you put a comma separator between the column and indicator variable in your Fetch Statement?
The following code snippet should work.
Note there is neither comma between :LocTS1 and :LocTS1Ind nor between :LocTS2 and LocTS2Ind!
DCL-S LocTS1 Timestamp;
DCL-S LocTS1Ind Int(5);
DCL-S LocTS2 Timestamp;
DCL-S LocTS2Ind Int(5);
DCL-S LocVarChar1 VarChar(10);
DCL-S LocDec1 Dec(11, 2);
Exec SQL Declare CsrC01 cursor for
Select TS1, VarChar1, TS2, Decimal1
From ...
Where ...;
Exec SQL Open CsrC01;
DoU 1=0;
Exec SQL Fetch Next From CsrC01
into :LocTS1 :LocTS1Ind, :MyVarChar1,
:LocTS2 :LocTS2Ind, :MYDec1;
If SQLCODE = 100
or SQLCODE < *Zeros;
//Handle SQL Error;
Exec SQL Close CsrC01;
Leave;
EndIf;
If LocTS1Ind = -1; //NULL value in Column TS1
//Handle NULL Value
EndIf;
If LocTS2Ind = -1; //Null value in Column TS2
//Handle NULL Value
EndIf;
EndDo;
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@xxxxxxxxxxxx> On Behalf Of Booth Martin
Sent: Sonntag, 18. März 2018 03:50
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: SQLRPGLE - Records with timestamp field as null not being selected
The data file has 2 timestamp fields that are allowed to be null. When I do a fetch on the file, records with null are not selected. I saw an instruction to add a 5i/0 field after the each timestamp and tried that with an SQLCode of -303 and no records at all were selected
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.