Home » SQL & PL/SQL » SQL & PL/SQL » Calling a sql script from a shell script
Calling a sql script from a shell script [message #236061] Tue, 08 May 2007 22:46 Go to next message
rcd70
Messages: 14
Registered: April 2006
Location: Auckland, New Zealand
Junior Member
Hi All

Can anyone please let me know how do I call a pls script from with a shell script. The connection information is in the pls script eg conn scott/ which asks for a password if I run it from sqlplus.

Is there any way of replicating this behaviour from shell script. I do not want to specify the user in the shell script when connecting to sqlplus as the user might change.

Any help apprecisted.

Regards
Rajesh
Re: Calling a sql script from a shell script [message #236104 is a reply to message #236061] Wed, 09 May 2007 01:05 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
sqlplus /nolog @your_script
Re: Calling a sql script from a shell script [message #236112 is a reply to message #236061] Wed, 09 May 2007 01:13 Go to previous messageGo to next message
bonker
Messages: 402
Registered: July 2005
Senior Member
you mean something like this

$cat pl.sql
conn scott@test
select * from dual;
exit
$
$sqlplus /nolog @pl.sql

SQL*Plus: Release 10.1.0.2.0 - Production on Tue May 8 23:42:21 2007

Copyright (c) 1982, 2004, Oracle.  All rights reserved.

Enter password:
Connected.

D
-
X

Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64
bit Production
With the Partitioning, OLAP and Data Mining options
$


Re: Calling a sql script from a shell script [message #236151 is a reply to message #236112] Wed, 09 May 2007 03:33 Go to previous message
gold_oracl
Messages: 129
Registered: July 2006
Location: Westborough, MA
Senior Member
If my understanding is correct, why dont you try like this within shell script.

CONNECT="$1/$2"
sqlplus ${CONNECT} @sql_file_name.sql

while execute the shell script pass username as the first parameter and password as second one.

Thanks,
Thangam
Previous Topic: Date shows 00/00/0000
Next Topic: DBMS_JOB Problem
Goto Forum:
  


Current Time: Fri Dec 02 13:56:22 CST 2016

Total time taken to generate the page: 0.11237 seconds