O'Reilly logo

Oracle® Web Application Programming for PL/SQL® Developers by Benjamin Rosenzweig, Solomon Morse, Melanie Caffrey, Susan Boardman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit 18.4. Use Dynamic SQL

What is Dynamic SQL?

Dynamic SQL allows you to construct a string and then run it as an SQL statement at runtime. It is useful when you do not know exactly what your SQL statement is going to look like. This might happen on the Web because you will run a different SQL depending on what a user submits in a FORM.

You can construct queries that have different conditions or different ORDER BY clauses. You can even decide to query completely different tables. You could also add optimizer hints to your query at runtime.

Along with SELECT queries, Dynamic SQL can be used to execute DDL within PL/SQL. Normally, you are not permitted to execute DDL such as a GRANT or CREATE TABLE or DROP SYNONYM statement. However, you can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required