If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > isnumeric

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-21-04, 10:14
kelvinpuk kelvinpuk is offline
Registered User
 
Join Date: Jul 2003
Posts: 23
Question isnumeric

Is there an informix equivalent to the function isnumeric() ?
Reply With Quote
  #2 (permalink)  
Old 06-22-04, 09:57
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
I don't think there is one, but you can create it very easily
using someting like

LET charstr = integer value

FOR i = 1 to LENGTH(charstr)
IF charstr[i] in (1,2,3,4 etc... ) THEN
-- do nothing
ELSE
ERROR "Not a numberic value"
RETURN FALSE
END IF
END FOR

I did not try it, Do not have access to 4gl but should work
Reply With Quote
  #3 (permalink)  
Old 06-23-04, 12:13
fprose fprose is offline
Registered User
 
Join Date: Apr 2003
Location: Phoenix, AZ
Posts: 177
This is what we use:

drop function isnumeric;
create function isnumeric(inputstr char(12)) returning integer;
define numeric_var decimal(12,6);
define function_rtn integer;

on exception in (-1213)
let function_rtn = 0;
end exception with resume

let function_rtn = 1;
let numeric_var = inputstr;

return function_rtn;
end function;


Fuction returns a "1" if numeric, "0" if non-numeric. I'm just trapping the numeric conversion error.
__________________
Fred Prose
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On