|
Does DDS defined files support nulls? Becuase the file is DDS defined.
--
Mike Wills
Midrange Programmer/Analyst
http://mikewills.info
http://www.linkedin.com/in/mikewills
On Tue, Jul 14, 2009 at 3:08 PM, Alan Campin <alan0307d@xxxxxxxxx> wrote:
This is a document I wrote up on nulls, RPG and SQL. Hope it is helpful.--
Using Nulls In RPG and SQL
If you have a table that supports nulls, you either need to read the record
in RPG and see if fields in the table are null or set the null condition
when you insert the record
The trick is not to put a comma between the list of variables. SQL
Pre-Compiler sees this and says this must be an indicator array.
In this example, I am using named indicators rather than NullInd(1), etc.
NullInd is mapped to dsNullInd so dsNullInd and the array NullInd are the
same thing.
Note that because I am using qualified data structures I can use the same
name for the null fields as the record fields.
d cSqlNotNullIndicator…
d c Const(0)
d cSqlNullIndicator...
d c Const(-1)
d dsRecord...
d ds Qualified
d CustName...
d Like(StdNam)
d CustLibrary...
d Like(StdNam)
d dsNullInd...
d ds Qualified
d CustName...
d 5i 0
d Inz(cSqlNotNullIndicator)
d CustLibrary...
d 5i 0
d Inz(cSqlNotNullIndicator)
d ptrNullInd...
d s Like(StdPtr)
d Inz(%Addr(dsNullInd))
d NullInd...
d s 5i 0
d Dim(2)
d Based(ptrNullInd)
Exec Sql Select Field1,
Field2
Into :dsRecord :NullInd
From FileY;
If dsNullInd.CustName = cNullIndicator; // If null in database.
// Do something
EndIf;
Or
Exec Sql Fetch From C1
Into :dsRecord :NullInd;
If dsNullInd.CustLibrary = cNotNullIndicator; // If not null.
// Do Something
EndIf
Or
Exec Sql Update FileY
Set(CustName = :CustName :NullInd)
Or
dsNullInd.CustName = cNullIndicator;
Exec Sql Insert Into FileY
Values(:dsRecord :NullInd);
RPG ends up looking like:
//****ec Sql Insert Into FileY
//**** Values(:dsRecordOut :NullInd);
C EVAL SQL_00005 = DSRECORD.CUSTNAME
C EVAL SQL_00006 = DSRECORD.CUSTLIBARY
C EVAL SQL_00007 = NULLIND(1)
C EVAL SQL_00008 = NULLIND(2)
On Tue, Jul 14, 2009 at 1:45 PM, Mike <koldark@xxxxxxxxx> wrote:
I don't understand what you mean.list
--
Mike Wills
Midrange Programmer/Analyst
http://mikewills.info
http://www.linkedin.com/in/mikewills
On Tue, Jul 14, 2009 at 2:41 PM, Mark Walter <mwalter@xxxxxxxxxxxxxxx
wrote:
You may need a null variable in your sql code.rpg400-l-bounces@xxxxxxxxxxxx]
Mark Walter
Business to Business Data Integration Specialist
Certified IBM System i Specialist
Paragon Consulting Services, Inc
mwalter@xxxxxxxxxxxxxxx
717-764-7909 ext. 126
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:
On Behalf Of Mikevalues
Sent: Tuesday, July 14, 2009 3:29 PM
To: RPG programming on the AS400 / iSeries
Subject: SQLSTT Error Code 01003
I am trying to figure out what this error means beyond "01003 - Null
removed from column function argument(s)." It is causing issues in mylist
program. I check to be sure that SQLSTT is 0 or 2000. This is the first
time
I have come across this error and the error message isn't very helpful
here.
--
Mike Wills
Midrange Programmer/Analyst
http://mikewills.info
http://www.linkedin.com/in/mikewills
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
To post a message email: RPG400-L@xxxxxxxxxxxxlist
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
To post a message email: RPG400-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
To post a message email: RPG400-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
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.