Using CAST Function in PL-SQL
619071Jan 22 2008 — edited Jan 22 2008Hello guys,
I'm writing a stored procedure which tries to convert a string representing a number to a fixed size number(with 2 positions fraction). For example, if the input was "15,456" the result would become 15.45.
I was able to aschieve this ussing the CAST function within a query as follows:
select cast ('15,456' as number(15,2)) from dual; -- (the comma in my case is configured as fraction separator). The previous query executes OK using a query analyzer like SQL Plus.
However, when I try to use the same function within a stored procedure, it will complain about the number's size (15,2) and wont compile.
v_importe_ingresado := CAST('15,456' AS NUMBER(15,2));
Error output: PLS-00103 found '(' but expected one of the following: .)@%
When removing the (15,2) it compiles ok
¿Any clue?
I will appreciate any help.
Thanks in advance,
Bernabé