Re: Checking datatype of CHAR variable in 4GL
Posted in 1998
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
I agree with the guy who said you need to resort to C to check whether the field is numeric or not. If you want some example 4gl and C code on how to do this drop a line at tycnine@flash.net. The catchall for case is "whenever else". case myfield when "A" do this whenever else do that end case Ben Knox <ben@dircon.net> wrote in article <34e2f2c8.0@newsread1.dircon.co.uk>... > Does anyone if there a function in Informix 4gl (version 4) which will let > you check the contents of a CHAR variable to see whether or not it is a > valid number, without causing a numeric conversion error? > > I have an application which is requesting input from the user, and the input > can be a number, or a string. This then gets put through a CASE statement, > more or less as follows: > > DEFINE > var CHAR(5) > > PROMPT "Enter data: " FOR var > > CASE > > WHEN var>=1 AND var<=9999 > DISPLAY "Var is a number" > WHEN var IS NOT NULL > DISPLAY "Var is a string" > END CASE > > The problem I've got is that if the user enters a string, the program bombs > out with a "Character to numeric conversion error" at the first WHEN clause. > > Lastly, does anyone know if there is a "catchall" WHEN statement (like the * > in a UNIX shell CASE statement). > > Thanks for any suggestions! > > Regards, Ben > > >