question

OracleApprender avatar image
OracleApprender asked

Can one use dynamic SQL within PL/SQL?

Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ? Thank you in advance.

oracleplsql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KillerDBA avatar image
KillerDBA answered

You can use dynamic SQL. The EXECUTE command is helpful for this. I supplied an example of that:

Elsewhere on Oracle Overflow

You can't use DDL in a regular stored procedure statement.

However, you can execute DDL with the EXECUTE statement. In fact, Oracle considers "TRUNCATE," which is in my example, to be DDL.

Here's a bit of explanation:

At Oracle-Base

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.