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 LEVELcommand at key steps in complex scripts to improve log readability. -
Use together with the
PWDcommand to display both current script and working directory during execution.
Syntax
show levelCommand Output Examples
SQL> show level
No script is currently activeSQL> show level
depth: 3
current: /path/to/nested/script.sqlSHOW 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 SCRIPTSto verify script call order and assist with troubleshooting. - Place
SHOW SCRIPTSnear the start of your top-level script to ensure complete script inclusion logs.
Syntax
show scriptsSQL> show scripts
scripts
├── main.sql
└── includes/setup.sqlPWDfor 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.
pwd
show scripts
show levelThis records the script's directory, stack, and nesting for clear, actionable logs.