-1

I am new to writing shell scripts. I want to connect to database and execute a simple query. Here is what i am trying

. /home/oracle/db_env.sh
sqlplus system/*****
select * from dual;

but when i execute this script i get nothing. when i exit out of sqlplus i get

bash: db.sh: line 3: syntax error near unexpected token `from'
bash: db.sh: line 3: `select * from dual;'

Kindly guide me how to.

1 Answer 1

0

Problem is that once your 'sqlplus system/****' executes, it is entering sqlplus command prompt, next line 'select * from dual;' is not passed by bash to that sqplus application prompt, and it is executed by bash directly.

You probably need something along like these suggestions:

https://stackoverflow.com/a/10278103/2002557

specifically something like:

/home/oracle/db_env.sh:

sqlplus -s <<EOF system/*****@<host name>/<db name>
select * from dual;
select something from somwhere;
# etc.
EOF
Sign up to request clarification or add additional context in comments.

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.