
How to Describe a Query at Run Time with DBMS_SQL.DESCRIBE_COLUMNS
Learn the names, types, and nullability of a query's columns at run time, and write PL/SQL that prints any query.
PL/SQL (Procedural Language for SQL) is Oracle's proprietary extension to standard SQL. It combines the data manipulation power of SQL with the procedural capabilities of a programming language. PL/SQL allows developers to write complex database-centric applications by incorporating variables, conditions, loops, error handling, and modular programming constructs like procedures and functions. This language is tightly integrated with Oracle databases, enabling efficient data processing and transaction management.

Learn the names, types, and nullability of a query's columns at run time, and write PL/SQL that prints any query.

Get the columns, keys, indexes, and statistics of a table, index, or view as one JSON document in Oracle AI Database 26ai.

Split a ROWID into its object, file, block, and row number to see where rows are stored, including in bigfile tablespaces.

Turn PL/SQL compiler warnings on, off, or into errors from code, read the current setting, and restore it afterward.

Print the source the PL/SQL compiler actually sees after conditional compilation, for stored units or source text.

Find out the parameters, types, modes, defaults, and overloads of any procedure or function at run time.

Read the database version and release as PL/SQL constants, and use them to compile the right code for each release.

Create random numbers, strings, and test rows, shuffle query results, and get repeatable sequences with a seed.

Make sure only one session runs a process at a time with named user locks, and read the result codes REQUEST and RELEASE return.

Throw away package variables and caches in the current session with RESET_PACKAGE or MODIFY_PACKAGE_STATE, and start clean.

Identify end users, change NLS settings, check roles, pause, and set application context values for the current session.

Publish how far a long PL/SQL batch job has got, with a message and a time estimate, in V$SESSION_LONGOPS.

Tell DBAs and monitoring tools what each session is doing by setting module, action, and client information from your code.

Replace every view and table SQL macro in a query with the SQL it stands for, to see what the database really runs.

Find out what an object name really refers to, through schemas and synonyms, and split or canonicalize names in PL/SQL.

Turn a comma-separated list of names into a PL/SQL table and back, and see why numbers and other values are rejected.

Measure how long PL/SQL takes with GET_TIME and GET_CPU_TIME, and compare the two to tell computing from waiting.

Find where your PL/SQL code is running and where an error came from, as separate values with subprogram names inside packages.