How to Exit from SQL*Plus Script if Substitution Variable is not Defined (Doc ID 393476.1)

Last updated on OCTOBER 28, 2016

Applies to:

SQL*Plus - Version: 10.1.0.4
Information in this document applies to any platform.

Goal

Is it possible to exit from SQL*PLUS with a return code when an SQL is executed with an undefined variable within a Unix shell script.

Example:
select &var1 from dual; --var1 is not declared within the script


Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms