I hate the date "12/31/1899"
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
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
Because there is no record matching with the given where criteria the
xdate variable assigned to '12/31/1899'. When this happens I want the
program to stop.
Because 'Status' and 'sqlca.errd[x]' don't work for declared SQL
statements I had to do the following after the 'END FOREACH' line:
IF xdate = "12/31/1899" THEN
ERROR"....."
SLEEP 2
EXIT PROGRAM
END IF
Actually I don't want to hard code this date in the code.
Any other alternatives will be gladly accepted.
Thanks,
Sinan.
Get Your Private, Free Email at http://www.hotmail.com
Hi Sinan,
I don't understand why you want to stop the program when xdate="12/31/1899"
, but anyway this is my best answer to your issue.
a. Try to initialize xdate to null before foreach.
b. Or before foreach, make a select count(*) if there are any records
year(date)="1990" then proceeds with the foreach.
c.Or within foreach put a variable for counting.
LET l_cnt =0
FOREACH ....
LET l_cnt = l_cnt + 1
.
.
.
END FOREACH
IF l_cnt = 0 THEN
EXIT PROGRAM
END IF
Kind Regards,
phil
In article <7e36ob$7mj$1@news.xmission.com>,
"Sinan UST" <sinanust@hotmail.com> 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
>
> Because there is no record matching with the given where criteria the
> xdate variable assigned to '12/31/1899'. When this happens I want the
> program to stop.
>
> Because 'Status' and 'sqlca.errd[x]' don't work for declared SQL
> statements I had to do the following after the 'END FOREACH' line:
>
> IF xdate = "12/31/1899" THEN
> ERROR"....."
> SLEEP 2
> EXIT PROGRAM
> END IF
>
> Actually I don't want to hard code this date in the code.
>
> Any other alternatives will be gladly accepted.
>
> Thanks,
>
> Sinan.
> Get Your Private, Free Email at http://www.hotmail.com
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own