parameters in PL/SQL script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parameters in PL/SQL script
# 1  
Old 03-09-2004
Question parameters in PL/SQL script

Hi ,
I am writing a unix script, calls an PL/SQL block which uses the parameters I passed to the Unix script.

There are 3 sets of parameters I am passing:
set 1 - a or b (only one parameter)
set 2 - 2 2 (two parameters)
set 3 - 2 10000 20000 (three parameters)

Now, my question is I want to use these parameters in my PL/SQL block. Can someone ....?
# 2  
Old 03-10-2004
reddyp,

Are you making calls to an stored procedure or a PL/SQL block that you are constructing on the fly? The following is an example of passing a couple of shell based parameters to a call to a stored procedure:

Given a shell script named test.ksh:

$ cat test.ksh

sqlplus -s username/password@sid << EOF
exec myproc(p_first => $1, p_second => $2, p_third => $3);
/
EOF

$ ./test.ksh 11 22 33

If I didn't understand your question correctly, please elaborate.

Cheers,

Keith
# 3  
Old 03-10-2004
Keith,

My intesion is to run a query on oracle database via., a unix script that can take upto 3 parameters as mentioned below:

$ ./test.ksh a (I am using only one parameter here)
$ ./test.ksh 1 1 (I am using 2 parameters here)
$ ./test.ksh 1 1000 99999 (I am using 3 parameters here)

Now, my requirement is to pass the total number of parameters supplied (i.e., $#) and all different parameters (i.e., $1, $2, $3) from this unix script to the my calling PL/SQL script (it is not a procedure or function) and I want to use these in IF clause of the PL/SQL block.

thanX.
# 4  
Old 03-10-2004
I don't know what PL/SQL is, so I may be off-base here. But I do know how to pass args from one ksh script to another. That turns out to be a rough problem because of this:
/some/script one "two three" four

With ksh, to pass those arguments as 3 arguments, you would use:
/some/other/script "$@"
but read on for another option.

If you used just:
/some/other/script $@
the "two three" would become 2 separate arguments.

And if you tried:
/some/other/script "$*"
you will pass only one argument. This is the difference between $* and $@.

With ksh, unlike the old bourne shell, if there are no argument at all,
/some/other/script "$@"
passes no arguments to the other script. With the bourne shell, you pass a single null argument, sort of like this:
/some/other/script ""

So with the old bourne shell, you had to use the syntax:
/some/other/script ${1+"$@"}
which still works with ksh. I think that syntax is clever and I'm used to it for passing all arguments to a inner command. So this is what I tend to use. Some people don't agree with me that ${1+"$@"} to more clear than "$@". Go figure.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. Shell Programming and Scripting

Linux parameters in SQL command

Hello. It's my first steps in creat bash skript. This is my skript : mysql -e " UPDATE datebase.table SET U_O_ID=NULL WHERE U_O_ID LIKE '"$w4"' AND N_U != '"$w1"' " -u admin -p""Password"" ; It doesn't work. I find a lot of topic about it, but I didn't find simple answer.... (7 Replies)
Discussion started by: karp
7 Replies

3. Shell Programming and Scripting

Shell script to run sql query having a long listing of parameters

Hi, I have a query regarding execution of a sql query having long listing of parameters ..I need to execute this query inside a shell script. The scenario is like.... Suppose I have a file abc.txt that has the card numbers..it could be in thousands.. then I need to fire a query like ... (12 Replies)
Discussion started by: vsachan
12 Replies

4. Shell Programming and Scripting

Calling sql file from shell script with parameters.

Hi, I am calling a sql file script.sql from shell script and passing few parameters also as shown below: sqlplus -S id/password @script.sql $param1 $param2 Now,In sql file I have to create a extract text file after querying oracle tables based on the parameters passed(param1,param2) as... (7 Replies)
Discussion started by: anil029
7 Replies

5. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

6. Shell Programming and Scripting

Run SQL with parameters from a file

Hello, I need to run a SQL which will get parameters from a .txt file. Basically I need to run following query select * from a table where identity_id in <list of values in A.txt file> A.txt file is having values 1 2 3 4 5 I need the SQL to pick the values from the file and... (2 Replies)
Discussion started by: asdban
2 Replies

7. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

8. Shell Programming and Scripting

Calling sql in shell script with parameters

Dear All, I want to call an sql script within a unix shell script. I want to pass a parameter into the shell script which should be used as a parameter in teh sql script. e.g $ ./shell1.sh 5000129 here 5000129 is a prameter inside shell script i am calling one sql script e.g. ... (2 Replies)
Discussion started by: Radhe
2 Replies

9. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

10. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies
Login or Register to Ask a Question