How to pass parameter from file to sqlplus in UNIX? [message #626929] |
Wed, 05 November 2014 06:50 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/7dbb35ce9fd8661520554fe13e5da7cd?s=64&d=mm&r=g) |
pallvi
Messages: 3 Registered: November 2014
|
Junior Member |
|
|
Hi,
I have one variable in which i am putting file content and in file account number are there, i have put quotes in file and putting that file in d variable.
d='cat u.txt'
and file content are
"'32432432432','32432432432','2343243223432'"
sqlplus -s user/password@servername @file.sql $d >> file1.txt
and file.sql have below code
define acct = &1;
select * from account where acct in ( &acct);
exit;
however this is not working, i have put set echo on in .sql, seems lile variable is not showing in .sql file.
Please help me how i can achieve this.
|
|
|
|
|
Re: How to pass parameter from file to sqlplus in UNIX? [message #626936 is a reply to message #626934] |
Wed, 05 November 2014 07:52 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Also, depending on what the SQL script expects in the variable, your might have to use backticks instead of single quotes when asigning the variable. See this example:
/tmp $ echo "Test" >tmp.file
/tmp $ d='cat tmp.file'
/tmp $ echo $d
cat tmp.file
/tmp $ d=`cat tmp.file`
/tmp $ echo $d
Test
|
|
|
|
|
Re: How to pass parameter from file to sqlplus in UNIX? [message #626943 is a reply to message #626940] |
Wed, 05 November 2014 08:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Well "not work" is pretty much useless as an error description. You have to show us what really happens, like this for example:
/tmp $ cat test.sql
define acct = &1;
select &acct from dual;
exit;
/tmp $ sqlplus user/pass @test.sql 999
SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 5 15:10:21 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
old 1: select &acct from dual
new 1: select 999 from dual
999
----------
999
Disconnected from Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
/tmp $
|
|
|
|
|