How to use parameter in sql script pass from unix script?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to use parameter in sql script pass from unix script?
# 1  
Old 03-31-2011
How to use parameter in sql script pass from unix script?

Hi,

I am unable to use parameter in sql script passed from unix script.

my sql script CREATE_SBI_LIST_GROUP.sql is like this -
-------------------------------
Code:
SELECT
SDS.ID "SO_ID",
SDS.SO a1,
sgp.sga__code SGA_CODE,
FROM
sga sga,sales_genl_provision sgp , comm_product_condn cpc ,SO_DETAILS_SBI_GROUP SDS
WHERE
sga.customer_group__code ='&1'  
-- &1 variable passed from unix script it is   not working here
and sga.code = sgp.sga__code
and sgp.sga__code = cpc.sga__code
;

Unix script is as like -
-----------------------------
Code:
    group="0023"
    sqlplus -s $USER <<EOF 1>>$SBI_LOG/oracle_error.log
        whenever sqlerror exit 1
        set serveroutput off;
        set echo off;
        set termout off;
        set linesize 600;
        set line 1000;
        set pagesize 5000;
        set newpage 0;
        set feedback off;
        set trimspool on;
        set trimout off;
        set define off;
        set verify off;
        set escape off;
        set colsep "|"
        set doc off;
        spool $SBI_LOG/$SPOOLFILE
        @CREATE_SBI_LIST_GROUP.sql $group  
        spool off;
        quit;
EOF

Please advice me what i am missing here.

Thanks
Amit

Last edited by pludi; 03-31-2011 at 05:48 AM..
# 2  
Old 03-31-2011
Quote:
Originally Posted by apskaushik
Code:
    group="0023"
    sqlplus -s $USER <<EOF 1>>$SBI_LOG/oracle_error.log
        whenever sqlerror exit 1
        set serveroutput off;
        set echo off;
        set termout off;
        set linesize 600;
        set line 1000;
        set pagesize 5000;
        set newpage 0;
        set feedback off;
        set trimspool on;
        set trimout off;
        set define off;
        set verify off;
        set escape off;
        set colsep "|"
        set doc off;
        spool $SBI_LOG/$SPOOLFILE
        @CREATE_SBI_LIST_GROUP.sql $group  
        spool off;
        quit;
EOF

Please advice me what i am missing here.

Thanks
Amit
You turned off variable substitution (in red above).
# 3  
Old 04-07-2011
Hi.

Thanks for your help , it resolved my query and i can use & in my script.

Thanks
Amit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass script with parameter in korn shell script

I have written a script which will take input parameter as another script. However, if the script passed as input parameter has parameters then this script doesn't work. I have a script b.ksh which has 1 and 2 as parameters I have a script c.ksh which has 3,4 and 5 as parameters vi a.ksh... (1 Reply)
Discussion started by: Vee
1 Replies

2. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (3 Replies)
Discussion started by: Debalina Roy
3 Replies

3. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (2 Replies)
Discussion started by: Debalina Roy
2 Replies

4. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

5. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script 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 -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

6. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

7. UNIX for Advanced & Expert Users

Pass parameter to the main script from wrapper script

Hi, I am writing a wrapper script(wrap_script.sh) to one of the main scripts (main_script.sh) The main script is executed as following: ./main_script.sh <LIST> <STARTDATE> <ENDDATE> looks for a parameter which is a LIST(consists of different list names that need to be processed), START/END... (0 Replies)
Discussion started by: stunnerz_84
0 Replies

8. Shell Programming and Scripting

Pass parameter from PL/SQL to Unix "as is"

Hi, I need to pass 4 parameters from Oracle Procedure to Unix Shell script.. procedure signature :- UNIX Shell script: Problem: 1. Suppose pdffile and pdfresult has Null values in Oracle procedures but unix shell will read parameters by spaces so I am getting wrong parameters... (7 Replies)
Discussion started by: sandy162
7 Replies

9. Shell Programming and Scripting

passing parameter from Shell-script to Sql-script

Dear Friends, Please help me to achieve the following: I want to pass one parameter from Shell-script to Sql-script. Example: My ShellScript.sh is calling report.sql like this: /bin/sqlplus /reports.sql And My report.sql is calling many Stored-Procedures like this: exec... (0 Replies)
Discussion started by: subodhbansal
0 Replies

10. UNIX for Dummies Questions & Answers

how to pass values from oracle sql plus to unix shell script

how to pass values from oracle sql plus to unix shell script (2 Replies)
Discussion started by: trichyselva
2 Replies
Login or Register to Ask a Question