I have been asked to change a part of the existing SQLPLUS script to a shell script to allow for more options.
Here is what the original SQLPLUS script was prompting for:
SPOOL results.txt;
WHENEVER OSERROR EXIT 9;
WHENEVER SQLERROR EXIT SQL.SQLCODE;
PROMPT
PROMPT This script upgrades the database to the most recent version of eV8.0.
SET VERIFY OFF;
SET SERVEROUTPUT ON;
ACCEPT continue_flag CHAR PROMPT 'Are You ready to continue Y/N? '
PROMPT
My shell script now looks like :
#!/bin/sh
echo "Please enter database username"
read eval_user
echo "Please enter database password"
read eval_pass
echo "Please enter the database name"
read db_name
$ORACLE_HOME/bin/sqlplus -s /nolog <<-EOF >> ${LOGFILE}
connect $eval_user/$eval_pass@$db_name
set serveroutput on format wrapped
set pages 0 lines 300 trimout on trimspool on
set echo off feedback off sqlprompt ''
SPOOL results.txt;
WHENEVER OSERROR EXIT 9;
WHENEVER SQLERROR EXIT SQL.SQLCODE;
PROMPT
SET VERIFY OFF;
SET SERVEROUTPUT ON;
ACCEPT continue_flag CHAR PROMPT 'Are You ready to continue Y/N? '
PROMPT
I get this error when the SQLPLUS prompt line is reached:
Are You ready to continue Y/N? You have entered an invalid response. Exiting.
BEGIN
*
ERROR at line 1:
ORA-06501: PL/SQL: program error
ORA-06512: at line 13
I am new to sqlplus, so I know it is something to do with the settings I set in the beginning, if I set echo off feedback off sqlprompt ' '. But, on removing the line, the script just hangs.
Should I take the prompts completely out of SQLPLUS and use it only in the shell part?
sqlpluswhen I wanted to execute it. The benefit being that the script generator can be complicated using all the power of Python/Perl. It's analogous to something likeecho rm afile.txtchecking the output and then doingecho rm afile.txt | shwhen ready to commit.