Re: pl/sql function
From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 11 Aug 1999 12:59:16 GMT
Message-ID: <37b772d3.4969635_at_newshost.us.oracle.com>
14 end;
15 /
String is not a number
Date: Wed, 11 Aug 1999 12:59:16 GMT
Message-ID: <37b772d3.4969635_at_newshost.us.oracle.com>
A copy of this was sent to DooHee Kim~ <4658291d_at_rigel.oac.uci.edu> (if that email address didn't require changing) On Tue, 10 Aug 1999 11:57:53 -0700, you wrote:
>Is there a function to check if a given string is iteger or not?
just try to convert it and if it works -- its a number, if not it is not a number. for example:
SQL> set serveroutput on SQL> set echo on SQL> _at_test SQL> declare 2 string varchar2(25); 3 begin 4 string := 'abc'; 5 5 declare 6 x number; 7 begin 8 x := to_number(string); 9 dbms_output.put_line( 'String is a number' ); 10 exception 11 when value_error then 12 dbms_output.put_line( 'String is not a number' ); 13 end;
14 end;
15 /
String is not a number
PL/SQL procedure successfully completed.
The declare/exception block shows how to test if something is a number and where the code for "it is a number" vs "its not a number" would go.
-- See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA Opinions are mine and do not necessarily reflect those of Oracle CorporationReceived on Wed Aug 11 1999 - 14:59:16 CEST