Home » Infrastructure » Unix » URGENT: Passing parameters from unix shell script to Sql
URGENT: Passing parameters from unix shell script to Sql [message #98295] Tue, 29 June 2004 05:26 Go to next message
Balaji
Messages: 102
Registered: October 2000
Senior Member
Hi,

Is there any possibility of taking a value from the shell script to the sql.

for eg.,

sqlplus -s <<EOF > screen_buffer.log

username/pwd

@$Path/file.sql

EOF

Suppose i have a procedure in the file.sql which accepts a number as a parameter. and i have the value for that number in the shell from where i invoke the sql. How can i get this value in SQL??

can anybody help me out in this pls??

Thanks & Regards,

Balaji.
Re: URGENT: Passing parameters from unix shell script to Sql [message #98296 is a reply to message #98295] Tue, 29 June 2004 09:11 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
replace each "~" with a "<"

#!/bin/ksh
v_limit=5

echo "====>Here is the first using a Here Document"
# note escaped $
sqlplus -s scott/tiger@dev ~~EOF > log1.txt
set pagesize 0 feedback off verify off heading off echo off
WHENEVER SQLERROR EXIT 1
SELECT name from v$parameter where rownum < $v_limit;
exit;
EOF

echo "====>Here is the second calling a separate sql script"
sqlplus -s scott/tiger @t.sql $v_limit > log2.txt

This is t.sql
=============
set pagesize 0 feedback off verify off heading off echo off
SELECT name from v$parameter where rownum < &1 ;
exit;
Previous Topic: Shell Script
Next Topic: File Creation
Goto Forum:
  


Current Time: Tue Sep 22 06:58:27 CDT 2020