Hi Dennis,
Yes, you can test if a null was assigned to a variable instead of using an
INDICATOR var. I use both techniques. As always with programming, there's more
than one way to skin a cat. For example, you can use a correlated SELECT
instead of a sub-SELECT in most cases.
A couple of uses for the IND VAR:
1. Suppose you have a routine that successively SELECTS INTO different vars and
you want to do the same thing if any is null. If you use the same indicator
variable all the time, code for testing for the NULL can be copied without
regard for the name of the variable SELECTed INTO.
2. If you are SELECTing into a (large) number of variables and you want to see
if ANY are null you can use:
IF var1 IS NULL OR var2 IS NULL OR var3 IS NULL... THEN
Or, if you have IND VARs vI1, vI2, vI3.... you can use
IF (.vI1+.vI2+.vI3+...)<>0 THEN
2b. Similarly, if you want to see if ANY of the vars have a non-null value, you
can use:
IF (.vI1*.vI2*.vI3*...)=0 THEN
Regards,
Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251
From: [email protected] [mailto:[email protected]] On Behalf Of Dennis McGrath
Sent: Friday, May 18, 2012 4:59 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Difference between "select into" and "setvar"
It seems that some users of this list find my statements below to be offensive.
I appoligize for any upset I may have caused.
Does anyone out there have an example of how they use use the indicator
variables after the data has been retrieved?
I'm always interested in making my code more efficient, and would welcome any
examples where this is acheived with indicator variables.
Dennis McGrath
[email protected]
[email protected]
On Thu, May 17, 2012 at 10:57 AM, Dennis McGrath <[email protected]> wrote:
Now that we can easily turn off the message about a null value being returned,
I find the indicator variables totally unnecessary code bloat.
In the rbase environment, at least, If I want to know if a null is returned I
can test the actual value returned. In over 25 years of progamming rbase, the
only use I ever had for the indicator variables was to avoid throwing the error
to make tracing easier.
Dennis McGrath
[email protected]
[email protected]