The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Invoking Oracle stored procedure in unix shell script hidnana Shell Programming and Scripting 1 10-15-2008 04:37 AM
Calling an Oracle Stored Procedure from Unix shell script Leojhose Shell Programming and Scripting 2 08-06-2007 03:00 AM
Execute an Oracle stored procedure from a shell scrip mh53j_fe Shell Programming and Scripting 1 06-03-2005 12:17 PM
calling stored procedure from shell script. priyamurthy2005 Shell Programming and Scripting 2 04-21-2005 04:10 PM
Oracle stored procedure. kamil UNIX for Advanced & Expert Users 2 11-05-2003 10:39 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-08-2005
Registered User
 

Join Date: Jun 2005
Posts: 26
Shell arrays in oracle stored procedure

Is it possible to pass unix shell arrays in Oracle stored procedure?
Is yes, how?
Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 06-08-2005
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
The answer is: that depends.

Not taking into account command line restrictions, which may prevent large arrays from being expanded to the command line without error;

further not taking into account if an interface for such a huge amount of passed variables is possible to realize in sqlplus or whatever you use to trigger the stored procedure;

you could use the variable expansion of the ksh to expand the content of an array:

Code:
# myarr[1]="foo"
# myarr[2]="bar"
# print - ${myarr[*]}
foo bar
#
bakunin
Reply With Quote
  #3  
Old 06-09-2005
Registered User
 

Join Date: Jun 2005
Posts: 26
Hi bakunin
Thanks for the response but I am looking for the syntax on how to pass unix shell arrays in Oracle stored procedure
Reply With Quote
  #4  
Old 06-09-2005
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
How are you currently executing your stored procedures via shell? Are you using a Here document ( << EOF .... EOF). If so, you might be able to use the syntax noted above
Reply With Quote
  #5  
Old 06-09-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
Bottom line is that you are not going to be able to pass the array by making a simple assignment to an Oracle stored procedure parameter or variable.

You can do one of the following:
  1. Pass the array as stated previous, which is essentially a space delimited string. The strored procedure or an anonymous PL/SQL block can then parse sting into an Index-by table (PL/SQL table).
    Code:
    # myarr[1]="foo"
    # myarr[2]="bar"
    # sqlplus user/pwd@db <<EOF
    BEGIN
        MyVar VARCHAR2(100) := '${myarr[ * ]}'; -- The star is separated by spaces because the code block was getting horked up
        -- The previous line is expanded as follows:
        -- MyVar VARCHAR2(100) :='foo bar';
        YourStoredProcedure (MyVar);
    END;
    /
    EOF
  2. Insert the array elements into a table and the stored procedure can then retrieve the values from the table. This can be a global temporary table since the data would be temporary in nature.

Thomas
Reply With Quote
  #6  
Old 06-09-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Another way to do this:
1. write the contents of the array to something like a pipe-delimited file
2. Write a PL/SQL wrapper for your SP that calls UTL_FILE to read in the file, and create an array out of it, then pass the array (table actually) to the SP.

There is no shortcut.
Reply With Quote
  #7  
Old 06-09-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
Quote:
Originally Posted by jim mcnamara
Another way to do this:
1. write the contents of the array to something like a pipe-delimited file
2. Write a PL/SQL wrapper for your SP that calls UTL_FILE to read in the file, and create an array out of it, then pass the array (table actually) to the SP.

There is no shortcut.
Oh yeah, there is this way too. I avoid using UTL_FILE. I usually want to minimize load time and UTL_FILE is notroiously slow, involves DBAs who resist helping developers (I am a DBA by the way ), and is counter intuitive when reading the input lines.

Thomas
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0