Click here to Skip to main content
15,889,428 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am writting a shell script, which handles DB(Oracle) table operations (create, update, alter, insert etc...)
For each operation I had written seperate shell script function.
Could you please tell me that, it is necessary to connect to oracle in every function with below line?

sqlplus -s scott/tiger << EOF

Please tell me the scope of this DB connection is functionwise or its overall to the script?

I had written a DB_Connection function with this statement and other functions are getting called from main function in script.
Main function includes DB_connection, Create_Table, inser_rows etc...functions.

So is it necessary to write this line in every function before writting any DDL statement.
E.g.
sqlplus -s scott/tiger << EOF
Select * from <table_name>
exit
EOF


Thanks in advance. :-O
Posted
Updated 16-Sep-10 21:06pm
v2
Comments
Sergey Alexandrovich Kryukov 27-Mar-13 18:14pm    
Shell script?! Why on Earth would you want it?
—SA
Prasad Khandekar 27-Mar-13 21:44pm    
I think Oracle must have been deployed on a *NIX platform, which is any way a preferred platform for Oracle. So shell scripts are best friends on these platforms.
Sergey Alexandrovich Kryukov 27-Mar-13 23:17pm    
Well, yes, on *NIX it's more usual; I just did not think it's *NIX...
—SA

1 solution

Hello Poonam,

The lines between <<EOF and EOF tags denotes the SQL commands being piped into the SQLPlus executable. Have a look at this[^] article. It's not like a Database Connection available in most of the programming languages which you open once and reuse everywhere, It's a pipe command.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900