× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Charles, 

What is the advantage to having a NULL capable database field, as opposed
to, say, blanks?  Wouldn't that be easier?

I ask because I don't understand.

Thanks,

Shannon O'Donnell

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Wilt, Charles
Sent: Thursday, May 18, 2006 2:53 PM
To: RPG programming on the AS400 / iSeries
Subject: RPG IV not up to the task of reading and writing to DB files....

<vent>

I've come to that conclusion after banging my head against the wall of
RPG's (lack of) NULL support.

I'm working on a new from the ground up application system that will
eventually take the place of a poorly designed and written monolithic
system we use right now.

I've tried to do things the "right" way, a DB that uses triggers,
constraints and null-capable fields;  RPG service programs containing
modularized code.

I keep banging my head against the fact that many of my procedures deal
with a variable that ends up in a NULL capable DB column.  At least if
my top level procedures get passed an OMIT'd variable, I can without
trouble pass that along to lower level procedures.  At the lowest level,
when I go to write to the database, I can check the parameter and if it
is OMIT'd I can set the DB null indicator.

Even with the above, the programs calling those top level procedures
have to jump through hoops to either OMIT or no OMIT the param.  At
least I don't have to code the multiple calls procedure each using a
different combination parameters to be OMIT'd.  Scott Klement and other
helped with way around that requirement by playing games with basing
pointers and local variables.  The games are not pretty, but they are
better looking than the alternative.

Still, I have procedures that really need some way to return or set a
reference variable to a NULL value.  Can't be done, there's no such
thing as a standalone null capable variable in RPG.

Sure I can include my own null indicator, and I'm going to have to, but
the resulting code is not pretty.

For crying out loud if the DB supports NULLs shouldn't the primary
programming language? 

This would be ideal:

D myVar           s             10a   ALWNULL
 /free
    myVar = DoSomething(var1:var2:var3);
    DoSomethingElse(var4:myVar);
 /end-free

Nope, instead I've got this crap...
D myVar           s             10a   based(ptrMyVar)
D myVarNULL       s               n   
D memMyVar        s             10a
 /free
    DoSomething(var1:var2:var3:myVar:memMyVarNULL);
    if not myVarNULL;
       ptrMyVar = %addr(memMyVar);
    endif;
    DoSomethingElse(var4:myVar);
 /end-free

Thanks for listening!
</vent>

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 thread ...

Follow-Ups:
Replies:

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

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.