Error in SQL*Plus when Using Shell Script (Doc ID 1472150.1)

Last updated on JUNE 02, 2017

Applies to:

SQL*Plus - Version 10.1.0.2 to 11.2.0.3 [Release Oracle10g to 11.2]
Generic UNIX

Symptoms

Disclaimer: The illustration here is provided by way of example only, and is not intended to replace or alter the way sql*plus works. Examples of analysis performed within this article are only examples. Oracle Support does not troubleshoot shell scripts or custom scripts and does not suggest using it on Production environment.

When using bash profile to execute SQL commands, it errors out when it encounters some special characters.

For example, consider the following script:

 The select count(*) from v_$session will work absolutely fine when issued directly using sqlplus, whereas when issued through shell script it errors out.

Cause

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