Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 31st, 2004, 09:20 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass an Array as a Parameter to a Stored Procedure

Hi could someone help me on the best way to pass an array as a Parameter to a Stored procedure. This this case I am passing the string 'Bob,Sue' as a parameter and then I want 'Bob' and 'Sue' to end up as items in an IN list in a select statement. I tried parsing the string 'Bob,Sue' to create a varibable whose value is = 'Bob','Sue' and then reference that varible in the Select statement but that did not seem to work. I have copied that code below. If parsing a parameter string in this way is not the best method to handle this could someone please let me know what a better alternative would be. I am running Oracle version 9i running on NT.


CREATE OR REPLACE package body test_package as
procedure proto2 (
p_cust_seg_nbr in VARCHAR2,
p_start_bk_mo in number,
p_end_bk_mo in number,
o_customer_cursor out T_CURSOR)
IS
loopcount number;
posofcomma number;
tempstr varchar2(200);
origtempstr varchar2(200);
reconstr varchar2(200);
begin
posofcomma := INSTR(p_cust_seg_nbr,',');
origtempstr := p_cust_seg_nbr;
loopcount := 0;
if posofcomma > 0 then
while posofcomma > 0 loop
tempstr := substr(origtempstr,0,posofcomma-1);
origtempstr := substr(origtempstr,posofcomma+1);
posofcomma := instr(origtempstr,',');
if loopcount > 0 then
reconstr := reconstr||chr(39)||tempstr||chr(39)||',';
else
reconstr := chr(39)||tempstr||chr(39)||',';
end if;
loopcount := loopcount + 1;
end loop;
reconstr := reconstr||chr(39)||origtempstr||chr(39);
end if;
open o_customer_cursor for
select
reconstr as reconstr,
ename from emp
where ename IN (reconstr)
;
end;
end test_package;
/
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass XML parameter to stored procedure BCullenward Classic ASP Databases 3 September 10th, 2008 02:07 PM
how to pass array to oracle stored procedure? zhao2007 Hibernate 1 March 21st, 2008 03:51 PM
pass null to the parameter in the stored procedure kokila BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 12th, 2007 03:02 AM
How to pass a parameter to a stored procedure? MaxGay2 VB.NET 2002/2003 Basics 1 November 8th, 2006 02:48 PM
Pass a List/Array to a Stored Procedure in SQL Ser sankar SQL Server 2000 4 November 11th, 2003 05:01 AM



All times are GMT -4. The time now is 06:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.