25

Dynamic SQL with the DBMS_SQL Package

In Chapter 17, “Native Dynamic SQL,” you encountered the concept of dynamic SQL where SQL statements are built on the fly in PL/SQL. You learned about a PL/SQL feature for creating and running dynamic SQL called native dynamic SQL. In this chapter, you will learn about a second option to write dynamic SQL, the Oracle-supplied package DBMS_SQL.

Even though PL/SQL code that uses native dynamic SQL is easier to understand and has better performance, in some instances the DBMS_SQL package must be used instead. The DBMS_SQL package is used for dynamic SQL in the following cases:

  • When the columns of the SELECT statement ...

Get Oracle PL/SQL by Example, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.