The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 07:37 AM
Calling an Oracle Stored Procedure from Unix shell script Leojhose Shell Programming and Scripting 2 08-06-2007 06:00 AM
Execute an Oracle stored procedure from a shell scrip mh53j_fe Shell Programming and Scripting 1 06-03-2005 03:17 PM
calling stored procedure from shell script. priyamurthy2005 Shell Programming and Scripting 2 04-21-2005 07:10 PM
Oracle stored procedure. kamil UNIX for Advanced & Expert Users 2 11-05-2003 01:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-08-2005
superprogrammer superprogrammer is offline
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
  #2 (permalink)  
Old 06-08-2005
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
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
  #3 (permalink)  
Old 06-09-2005
superprogrammer superprogrammer is offline
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
  #4 (permalink)  
Old 06-09-2005
google's Avatar
google google is offline Forum Advisor  
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
  #5 (permalink)  
Old 06-09-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
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
  #6 (permalink)  
Old 06-09-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
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.
  #7 (permalink)  
Old 06-09-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0