0

I have the below shell script that calls an sql script. The problem is it calls the sql script, i enter the username,password ,dbname and after that it creates the table but it doesn't exit from the sql prompt.

test.sh

#!/usr/bin/ksh


sql_test=test.sql

$ORACLE_HOME/bin/sqlplus /nolog @${sql_test}

exit

test.sql

CONNECT &&usr/&&password@&&dbname


CREATE TABLE report1
(
    product_code                       VARCHAR2(30)
  , test_inc                           NUMBER(20,2)

);

2 Answers 2

3

Shouldn't you also put an exit statement in test.sql ?

Sign up to request clarification or add additional context in comments.

1 Comment

EXIT is exactly what is needed.
1

Or you could use a HERE document to eliminate the need to put the exit command into the SQL file:

$ORACLE_HOME/bin/sqlplus /nolog << HERE
@${sql_test};
exit sql.sqlcode
HERE

Share and enjoy.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.