|
Bob, Asking what's a "NULL variable" is a good question. The only answer I can come up with is, it depends! <grin> I don't know how oracle stores strings. But for example, CREATE TABLE CMWTEST (F1 VARCHAR (10 ) NOT NULL) INSERT INTO cmwtest VALUES('') Fails in Oracle, ORA-01400: cannot insert NULL into <...> Whereas it works fine in DB2. As far as RPG and "full NULL support", what I mean is given this code: If not %nullind(someDate); //do something with some date Endif; Will work if somedate is a field in a table, but it won't work if somedate is an RPG internal field. So when using RPG with files that support NULL, you have to do something like If someDateValid; %nullind(fdate) = *OFF; fdate = someDate; Else; %nullind(fdate) = *ON; Endif; If RPG had full NULL support, you could simply have: fdate = someDate; If someDate was NULL, then fdate would be null. Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121 > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Bob Cozzi > Sent: Friday, January 27, 2006 3:05 PM > To: 'RPG programming on the AS400 / iSeries' > Subject: RE: %Trim dilemma > > What's a "NULL Variable"? > Do you mean a field that can contain a X'00' or is considered > null (as in > *NULL in RPG IV)? > Does Oracle use null-terminated strings? If so, then a > pointer to a null > value is an empty string. A null pointer is the same in > Unix-based C as it > is in RPG IV, for the most part. > Often C compilers map a 0 or X'00' to the word "null". > So if (mystring == null) means, does the field contain a > X'00' in position > 1 (or offset zero of you're a C person). > In RPG IV, you can use %str() to move from/to null-terminated > strings. But > you're right, there is not "full null support" (whatever that > might mean, > but I agree that it seems that way). > > So if the l-value's length is ZERO, how many 9's should it be > compared with > in order for it to be false? Based the way *ALL'9' works, by > matching its > corresponding value's length, that would be zero 9's. Hence, > they would be > equal. > I've written tons of C code, and often have to check for a > null address/ptr > as well as a null value (pointing to X'00') to make sure I'm > not screwing > things up. Doing the following in this case, doesn't seem to strange. > I think this is just one of education, and acceptance. Now > let's get on with > the real problems in RPG IV, like hyphens in opcode names! <vbg> > > if %len(%Trim(myField)) > 0 > and %Trim(myField)= *ALL'9' > // now we're cookin' > endif > > -Bob Cozzi > www.RPGxTools.com > RPG xTools - Enjoy programming again. > > > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx] > On Behalf Of Wilt, Charles > Sent: Friday, January 27, 2006 1:52 PM > To: RPG programming on the AS400 / iSeries > Subject: RE: %Trim dilemma > > That's debatable, particularly when dealing with a language, like RPG, > that doesn't provide full NULL support. > > If you consider strings to be sets of characters, then you'd consider > that in set theory the NULL set and the EMPTY set are one and > the same. > > Interesting tidbit, Oracle treats EMPTY strings as NULL > strings and vice > versa. > > However, given that DB2 doesn't treat NULL strings as EMPTY > strings, and > given that RPG doesn't support NULL variables, I probably should have > said empty instead of NULL <grin> > > > Charles Wilt > -- > iSeries Systems Administrator / Developer > Mitsubishi Electric Automotive America > ph: 513-573-4343 > fax: 513-398-1121 > >
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.