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!

execute immediate

vpolasaDec 5 2007 — edited Dec 6 2007
I'm trying to add/subtract two numbers with the help of an operand which I pass it dynamically. This is the errror I got while trying to execute..

ORA-00923: FROM keyword not found where expected

DECLARE

sortOrd_in NUMBER;
v_operand VARCHAR2(1);
v_result NUMBER;
stmt VARCHAR2(4000);

BEGIN

sortOrd_in := 3;
v_operand := '+';

stmt := ('SELECT '||sortOrd_in||':1'||24||' FROM DUAL');

EXECUTE IMMEDIATE stmt INTO v_result USING v_operand;

dbms_output.put_line (v_result);

END;

I guess the error is in the stmt. But I'm unable to figure it out the exact syntax. What would be the correct syntax. Thanks and Regards.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2008
Added on Dec 5 2007
4 comments
1,235 views