Re: pl/sql function
From: Kenneth C Stahl <BluesSax_at_Unforgettable.com>
Date: Wed, 11 Aug 1999 08:10:53 -0400
Message-ID: <37B1684C.BCA94BA5_at_Unforgettable.com>
End if;
Result := True;
Return(0);
exception
end;
Date: Wed, 11 Aug 1999 08:10:53 -0400
Message-ID: <37B1684C.BCA94BA5_at_Unforgettable.com>
DooHee Kim~ wrote:
> Is there a function to check if a given string is iteger or not?
No, but it only takes a few seconds to write:
function IsInteger (Buff varchar2,bool INOUT Result) Return integer is
NotInteger Exception;
Val1 Number;
Val2 Integer;
begin
Val1 := To_Number(Buff);
Val2 := Trunc(Val1,0);
if Val1 != Val2 Then
Raise NotInteger;
End if;
Result := True;
Return(0);
exception
when invalid_number
Result := False
Return(0);
when NotInteger Then
Result := False
Return(0);
when others then
dbms_output(sqlerrm(sqlcode));
return(1);
end;
when the function returns, check the return value to see if it is 0. If it is, then check the boolean variable passed as the second parameter. If it is True then the buffer held an integer string, otherwise it was either a decimal value or was not a number at all.
Ken Received on Wed Aug 11 1999 - 14:10:53 CEST
