shell script: Bind variable not declared


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script: Bind variable not declared
# 1  
Old 05-29-2009
shell script: Bind variable not declared

Hi Friends,

I am trying to run a sql query from shell script as below but I get "Bind variable "1" not declared" error.

1.sh shell script has following:
sDb="abc/xyz@aaa"
a="1.sql"
sqlplus -s $sDb @$a $1

1.sql file has following:
spool Result.tmp append
select cust_name from orders where order_id=&1;
spool off;
exit;

I execute shell script as below:
1.sh 1234

It creates the Result.tmp but has following error:
Bind variable "1" not declared

Thank you so much,
Prashant
# 2  
Old 05-30-2009
what is that "&1" ??
if you wanna pass a argument to sql query
just write as shown below
Code:
sDb="abc/xyz@aaa"
a="1.sql"
sqlplus -s $sDb <<EOF
@$a $1
EOF

1.sql should be
Code:
spool Result.tmp append
select cust_name from orders where order_id=$1;
spool off;
exit;

or else
Code:
sqlplus -s abc/xyz@aaa <<EOF
spool Result.tmp append
select cust_name from orders where order_id=$1;
spool off;
exit;
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining a declared variable with a temporary variable

Hi folks! Kind of a noob question... from an OLD AIX/HPUX Admin. I am writing a script to ease use of a command; an extended aliasing if you will. What I want to do is set several variables (OPT1, OPT2, etc) with command arguments, such as --help, --list-all, etc. Later in the script, I... (5 Replies)
Discussion started by: clee
5 Replies

2. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies

3. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

4. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

5. Shell Programming and Scripting

write in file using printf with variable declared with a phrase

Hi guys, kinda new to unix/linux, could you please help me figure this out. i need to write in a file using printf. printf "%-20s %-40s %-20s\n" $a $b $c >> out.txt but a, b and c are declared in a header file: a='I am a dog' b='I am a cat' c='I am a fish' i want the file to look like... (1 Reply)
Discussion started by: kokoro
1 Replies

6. Shell Programming and Scripting

Passing variable from shell script to python script

I have a shell script main.sh which inturn call the python script ofdm.py, I want to pass two variables from shell script to python script for its execution. How do i achieve this ????? Eg: main.sh a=3 b=3; c= a+b exec python ofdm.py ofdm.py d=c+a Thanks in Anticipation (4 Replies)
Discussion started by: shashi792
4 Replies

7. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

8. Shell Programming and Scripting

How to return a value of a variable from shell script to perl script

HI , Is there any way to return a value of variable from shell to perl script. Code: === Perl file my $diff1=system("sh diff.sh"); my $diff2=system("sh diff1.sh"); I need exit status of below commands i.e 0 and 1 respectively. Since in both the cases diff is working so system... (3 Replies)
Discussion started by: srkelect
3 Replies

9. Shell Programming and Scripting

stored procoedure bind variables in shell

Hi , I have a pl/sql procedure which takes its input from a shell script, and deletes rows from db table based on the input. I've dbms_output.put_line statments in procedure which i want to capture and display in the script for example, if no rows have been deleted, i have to stop executing... (1 Reply)
Discussion started by: justchill
1 Replies

10. Shell Programming and Scripting

accessing variables declared in another perl script

Hi all, I have a perl script which declares two variables and calls another perl script which accesses those variables. But I am unable to access the variables in the called script. My script is as follows: my $ENV{a}="20"; system("perl called.pl"); and my called.pl contains: print... (3 Replies)
Discussion started by: gurukottur
3 Replies
Login or Register to Ask a Question