|
<snip>
>By the way how do you test if a field resulting from an
>embebbed sql statement is null? I don't know how to handle
>since is not the same as RPGIV. Somebody know other ways?
Marco Facchinetti
<snip>
Here's two examples of how to handle SQL Null fields in RPGIV.
Note: The DB field doesn't contain a null character(no such thing).
You have to test the Indicator Variable associated with the field. In
the example below, SalesNull is an Indicator Variable that will be a -1
if it's associated field DSCustSales is null during the fetch function.
On an Insert, You would say something like < C Eval SalesNull
= -1 > Then do an Insert to write DSCustSales as Null.
BTW, I do in house classes on this stuff if anyone is interested.
D SalesNull S 4B 0
C/Exec SQL
C+ Select CustId,
C+ CustNam,
C+ CustSales
C+ Into: :DSCustId,
C+ :DSCustName,
C+ :DSCustSales :SalesNull
C+ From Customer Where CustId = 'ACME'
C/End-Exec
---------
Here's how you would do an array of Null capable fields into a D/S You
have a D/S to put the individual fields you are fetching into and (followed
by a colon) is a structure of an array of binary fields to hold the null
representation of each of those fields.
D CustomerR DS
D CsCustID 7P 0
D CsName 30A
D CsShpCity 30A
D CsDiscount 5P 3
D CustomerIDS DS
D CsIDNull 4B 0
D CsNameNull 4B 0
D CsShpCityNull 4B 0
D CsDiscountNull 4B 0
D*
D CustomerI 4B 0 Dim(4) overlay(CustomerIDS)
C/Exec SQL
C+ Select CustID,
C+ Name,
C+ ShpCity,
C+ Discount
C+ Into :CustomerR :CustomerI
C+ From Customer
C+ Where CustID =:SelCst
C/End-Exec
John Carr
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.