Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using CAST Function in PL-SQL

619071Jan 22 2008 — edited Jan 22 2008
Hello 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é
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2008
Added on Jan 22 2008
3 comments
4,667 views