11.25 SHOW LEVEL and SHOW SCRIPTS

Oracle SQLcl provides script execution diagnostic commands, SHOW LEVEL and SHOW SCRIPTS, to help understand and audit the execution context and structure of SQL scripts. These commands offer visibility into which scripts are running, how scripts are nested, and the call order of included scripts. They do not require a database connection and can be used at any time for effective troubleshooting.

SHOW LEVEL

Use this command to display the current nesting level of script execution and the file that is currently being executed. The nesting level reflects how many scripts deep you are; each script included within another increases the level by one.

By showing how many scripts deep you are, it lets you know many layers of script calls have been made from the top-level script down to the current one. It gives you clear insight into the execution context. This helps to track the position within nested scripts, understand the depth of script execution, and more easily troubleshoot issues that arise in complex, multi-script environments.

Usage Notes

  • Use SHOW LEVEL command at key steps in complex scripts to improve log readability.

  • Use together with the PWD command to display both current script and working directory during execution.

Syntax

show level

Command Output Examples

When no script is running:
SQL> show level
No script is currently active
When running nested scripts:
SQL> show level
depth: 3
current: /path/to/nested/script.sql

SHOW SCRIPTS

Use this command to display a tree structure of scripts, showing the call order from the top-level script down to the currently running script. This helps visualize script inclusion and nesting during execution.

This tree structure visualization lets you see how scripts are organized and included, revealing the hierarchy and flow between scripts during execution. Such visibility is especially useful in troubleshooting and audits, as it helps you confirm which scripts are involved and how control moves through nested includes or calls. This makes it much easier to navigate, maintain, and debug complex script environments where multiple scripts are interdependent.

Usage Notes

  • Execute SHOW SCRIPTS to verify script call order and assist with troubleshooting.
  • Place SHOW SCRIPTS near the start of your top-level script to ensure complete script inclusion logs.

Syntax

show scripts
Example
SQL> show scripts
scripts
├── main.sql
└── includes/setup.sql

PWDfor Script Execution Context

PWD command complements script execution diagnostics by displaying the directory associated with the currently running script. When executed during script execution (even inside nested scripts), it shows the directory context so you know where relative paths resolve.

The PWD command has been enhanced to support script execution mode. Previously, PWD displayed your current working directory at the prompt, regardless of script activity. Now, when you execute a script—or a nested script—PWD shows the directory of the script that is currently being executed. This provides you with precise context for where relative paths will resolve, greatly aiding the debugging and development of complex script environments.

Recommended sequence at the start of included scripts:
pwd
show scripts
show level

This records the script's directory, stack, and nesting for clear, actionable logs.