Date vs Char -1218
Posted in 1999
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Hello Anybody know a (simple) work-around. The following 4gl will accept any valid date. The DBDATE is set to DMY4 MAIN DEFINE tempDate DATE DEFINE tempChar CHAR(15) LET tempChar = arg_Val(1) LET tempDate = tempChar DISPLAY tempDate END MAIN The 4gl will also accept a date "19/0899" However if I do a select stmt with this date I get a SQL 1218 error. I can see why there may be problems with allowing the engine to recognise incorrect dates - However I would assume that if my 4gl program will confirm that a variable is a valid date then I should be able to prepare a select stmt with this date without getting any errors. The real application is actually New-Era 2.20 and the engine is 7.30UC3. Any help appreciated. Jo Cooper ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
Excuse me, but while I do not get any error from the assignment to tempDate I also get no output from the display. The date is apparently not set by the assignment and is NULL. I modified your test program as shown and got the results shown below: Art S. Kagel Joseph Cooper wrote: > > Hello > Anybody know a (simple) work-around. > > The following 4gl will accept any valid date. > The DBDATE is set to DMY4 > > MAIN > DEFINE tempDate DATE > DEFINE tempChar CHAR(15) > LET tempDate = "1/1/1999" DISPLAY tempDate > LET tempChar = arg_Val(1) > LET tempDate = tempChar IF STATUS != 0 THEN DISPLAY "Error assigning date: ", STATUS ELSE IF tempDate IS NULL THEN DISPLAY "tempDate is NULL!" END IF END IF DISPLAY tempChar > DISPLAY tempDate > > END MAIN > c4gl -o testdate testdate.4gl > > testdate 19/0899 01/01/1999 tempDate is NULL! 19/0899 > You need to start protecting your code from invalid data! Art S. Kagel > The 4gl will also accept a date "19/0899" > However if I do a select stmt with this date I get a SQL 1218 error. > > I can see why there may be problems with allowing the engine to recognise > incorrect dates - However I would assume that if my 4gl program will confirm > that a variable is a valid date then I should be able to prepare a select > stmt with this date without getting any errors. > > The real application is actually New-Era 2.20 and the engine is 7.30UC3. > > Any help appreciated. > Jo Cooper > > ______________________________________________________ > Get Your Private, Free Email at http://www.hotmail.com