
How to Use DBMS_SESSION in Oracle
Identify end users, change NLS settings, check roles, pause, and set application context values for the current session.

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.

Speed up compute-heavy PL/SQL with native compilation, and hide the source of procedures and package bodies by wrapping them.

Find code that compiles but is probably wrong, such as unreachable lines, with PLSQL_WARNINGS, and make the worst ones errors.

Keep debug code and version-specific code in one PL/SQL source, and choose what is compiled with PLSQL_CCFLAGS and DBMS_DB_VERSION.

Build parameterized views and reusable query shapes with functions marked SQL_MACRO(TABLE), which Oracle expands into the calling query.

Record who connects with AFTER LOGON triggers and keep a history of schema changes with AFTER DDL triggers, and manage your triggers.

Let many transactions update seats, stock, or balances on the same row at once with reservable columns, while constraints still hold.

See how a deadlock happens and how Oracle breaks it with ORA-00060, where it is recorded, and how to keep deadlocks from recurring.

Lock the rows you read until you update them with SELECT FOR UPDATE, and use NOWAIT, WAIT, and SKIP LOCKED to control waiting.

Choose between READ COMMITTED, SERIALIZABLE, and READ ONLY transactions in Oracle, and know what each query sees and when ORA-08177 appears.

Reuse an expression across queries with a function marked SQL_MACRO(SCALAR), which Oracle expands into plain SQL when the query is parsed.