Home » Infrastructure » Unix » How would I pass database column values to a UNIX shell script
How would I pass database column values to a UNIX shell script [message #10634] Thu, 05 February 2004 18:01 Go to next message
GOMES
Messages: 2
Registered: February 2004
Junior Member
I have a oracle stored procedure that returns the following values:

directory path

directory name

file name 

program name

I am trying to pass these out parameter values in a shell script  to process the file on the on directory and path returned by the stored procedure.

Any help is appreciated.

Thanks
Re: How would I pass database column values to a UNIX shell script [message #10641 is a reply to message #10634] Fri, 06 February 2004 08:47 Go to previous message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
Ok,lets see an example,

-- Lets create a small procedure that will OUT 3 values

"afiedt.buf" 8 lines, 144 characters 

  1  create or replace procedure test(var1 out varchar2 ,var2 out varchar2,var3 out varchar2)
  2  as
  3  begin
  4  var1 := 'X';
  5  var2 := 'Y';
  6  var3 := 'Z';
  7* end;
SQL> /

Procedure created.

-- A sql script that will call this procedure and select the 3 OUT values

$cat pass_out.sql
set feedback off heading off pagesize 0 trimspool on
variable var1 varchar2;
variable var2 varchar2;
variable var3 varchar2;
execute test(:var1,:var2,:var3);
select :var1,:var2,:var3 from dual;
exit;

-- A shell array declared and initialised with the 3 variables through sqlplus

$set -A file_var `sqlplus -s thiru/*** @pass_out`

-- Access the Array variables in your shell script

$print ${file_var[0]} ${file_var[1]} ${file_var[2]}
X Y Z



-Thiru
Previous Topic: Bash Shell Question
Next Topic: Agent Configuration Assistant Failed during install
Goto Forum:
  


Current Time: Thu Apr 18 13:17:39 CDT 2024