Re: I hate the date "12/31/1899"
Posted in 1999
Mike Segel wrote:
> Sinan UST wrote:
> >
> > Hello to all,
> >
> > One of the programs that I am modifying for Y2K complaint has following
> > SQL statement (4GL 7.20 UD6):
> >
> > DECLARE c_date CORSOR FOR
> > SELECT date
> > FROM date_tbl
> > WHERE year(date) = "1990"> >
> > FOREACH c_date INTO xdate
> > .
> > .
> > END FOREACH
> >
> [SNIP]
>
> Caveats:
> I haven't touched 4GL in 4-5 years so I may be a tad rusty.
>
> My guess is that you have a null set returned from the query.
> That is, if there is no dataset returned from the query,
> the FOREACH isn't entered.
>
> It also looks like the date is initialized to 0 or -1.
> (I forget if Informix date 0 is 12/31/1899 or 01/01/1900.)
0 = 12/31/1899
And testing for the date being set to this when no rows are returned does not
sound like a good programming practice to me. But then, it's been a long
time since I was a programmer.
> The simplest thing to do is to have a flag that gets set true
> in your foreach, or you could use a counter.
Yup, that's a good one.
Otherwise:
DECLARE c_date CURSOR FOR ...
OPEN c_date
FETCH c_date INTO xdate
IF sqlca.sqlcode = 100 THEN
ERROR "....."
SLEEP 2
EXIT PROGRAM
END IF
WHILE sqlca.sqlcode = 0
...
FETCH NEXT c_date INTO xdate
END WHILE
June
--
june_t@hotmail.com
Back in Palo Alto, living on Kit Kat bars and chocolate chip cookies
Please do not send Informix questions to this account.
I would add 'Please do not send spam to this account'
but I suppose I would be wasting my bits.