Check variable of cursor negative or not? -- error [message #344224] |
Fri, 29 August 2008 02:25  |
JuzMe
Messages: 6 Registered: August 2008 Location: Singapore
|
Junior Member |
|
|
I understood I should use the Sign variable like this: SIGN(variable)
However when I tried this to check if my variable is negative:
IF SIGN(c3_rec.amount) = -1 then
-- c3_rec.amount is variable from cursor
I encountered this error:
PLS-00103: Encountered the symbol "SIGN" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "SIGN" to continue.
How do I solve this error?
|
|
|
Re: Check variable of cursor negative or not? -- error [message #344237 is a reply to message #344224] |
Fri, 29 August 2008 03:04   |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
I am afraid that you have syntax error in the piece of code you did not post, as SIGN function may be used in PL/SQL expression at least in Oracle 10g (as you did not post yours, I suppose that you use the supported one), as demonstrated below: SQL> set serveroutput on
SQL> declare
2 cursor c_test is
3 select level - 2 val from dual connect by level <= 3;
4 begin
5 for r_test in c_test loop
6 if sign( r_test.val ) = -1 then dbms_output.put_line( to_char(r_test.val)||' is negative' );
7 else dbms_output.put_line( to_char(r_test.val)||' is positive' );
8 end if;
9 end loop;
10 end;
11 /
-1 is negative
0 is positive
1 is positive
PL/SQL procedure successfully completed.
SQL>
|
|
|
|
|
|