8-13. Switching Between DBMS_SQL and Native Dynamic SQL

Problem

Your consulting company is currently migrating all its applications from using DBMS_SQL to native dynamic SQL. To help ensure that the migration can be done piecemeal, you want to provide the ability to switch between the two different techniques so that legacy code can coexist with the newer native dynamic SQL.

Solution

When you need both the DBMS_SQL package and native dynamic SQL, you can switch between them using the DBMS_SQL.TO_REFCURSOR and DBMS_SQL.TO_CURSOR_NUMBER APIs. The DBMS_SQL.TO_REFCURSOR API provides the ability to execute dynamic SQL using the DBMS_SQL package and then convert the DBMS_SQL cursor to a REF CURSOR. The DBMS_SQL.TO_CURSOR_NUMBER API allows for executing ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.