2

I would like to modify a value by using a dynamic sql statement. The example is choosen to be reproductible. I know that I don't need a dynamic sql statement for that.

variable a number =1;
print a 

1

exec execute immediate 'select 2 into :a from dual'

PL/SQL procedure successfully completed.

 print a

1

1 is returned instead of 2, which means that my statement wasn't executed.

So, how can it be executed?

1 Answer 1

3

INTO should be out of execute immediate:

SQL> var a number = 1;
SQL> print a

         A
----------
         1

SQL> exec execute immediate 'select 2 from dual' into :a;

PL/SQL procedure successfully completed.

SQL> print a

         A
----------
         2

SQL>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.