• Subject: RE: Null indicator with FETCH for N ROWS WAS: SQL pre-compiler
  • From: Buck Calabro <mcalabro@xxxxxxxxxxxx>
  • Date: Thu, 29 Jul 1999 09:38:18 -0400

>It works! Yeah!  I tried your array definition and it works.  
>All the IBM manuals and all the SQL books I've consulted 
>are wrong, wrong, wrong, and you are right!  

With all due respect, I got my info from the manuals.  Perhaps the V4R3
manuals I'm using are clearer?  Section 14.6 of the DB2 for AS/400 SQL
Programming V4R3 manual shows the use of an array rather than individual
fields.

>>This works:
>>DRtnNullRaw       ds                  occurs(10)
>>D NullMap                        4b 0 dim(9)
>
>All the reference books I've found, show:
>
>DRtnNullRaw         ds                  occurs(10)
>D NullField1                       4b 0
>D NullField2                       4b 0
>D NullField3                       4b 0
>D NullField4                       4b 0
>
>Your way does, indeed, work.
>
>One other question did come up in my research that I 
>haven't seen mentioned anywhere else.  In section 9.1.2 
>of the "DB2 for AS/400 SQL Programming V4R3, it states 
>" If the value for the result column causes a data mapping
>error, SQL sets the indicator variable to -2."  
>What exactly does this mean?

Say you are FETCHing a field that has 9 digits into a host variable of 5
digits.  That's a mapping error because you'll be losing information.  There
are other instances (decimal data error?) but I'm at a loss to name them :-)

>I'm currently only testing for -1 (nulls).  I've never seen any other
>examples of code that tests the null indicator for anything but nulls.  
>This makes me think I should also be testing for -2.  
>Do you do this and if so, what do you do with the base field 
>when you get a hit?  Clear it?

I haven't been testing for -2, because the SQL stuff I'm working on is
"proof of concept" type stuff rather than production (and I haven't got that
far!)  When I get to that point, I'll be checking for -2 (actually a named
constant) and reporting back an error so that the problem can be looked at.

Buck Calabro
Billing Concepts Albany, NY
mailto:mcalabro@commsoft.net

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].