Home » SQL & PL/SQL » SQL & PL/SQL » Passing an collection of data as an input parameter to an procedure and insert them into a table? (11g running on Windows)
Passing an collection of data as an input parameter to an procedure and insert them into a table? [message #604458] Tue, 31 December 2013 01:05 Go to next message
ashwanth77
Messages: 95
Registered: April 2013
Location: India
Member
I'm trying to pass an collection of (varchar) data into an Oracle procedure


pr_savecust_bill(
product_id(1,2,3,4,5,6,7,8,9,10,11,12..so on

);
Re: Passing an collection of data as an input parameter to an procedure and insert them into a table? [message #604459 is a reply to message #604458] Tue, 31 December 2013 01:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Here's an example:
SQL> create or replace procedure p (p_in sys.odcivarchar2list, p_out out varchar2, p_nb out int)
  2  is
  3    res varchar2(32000);
  4  begin
  5    p_nb := p_in.count;
  6    for i in 1..p_in.count loop
  7      res := res || ' ' || p_in(i);
  8    end loop;
  9    p_out := substr(res,2);
 10  end;
 11  /

Procedure created.

SQL> var result varchar2(4000)
SQL> var nb number
SQL> set autoprint on
SQL> exec p (sys.odcivarchar2list('Michel','Cadot'), :result, :nb);

PL/SQL procedure successfully completed.

        NB
----------
         2

RESULT
-------------------------------------------------------------------------------------------------
Michel Cadot

[Updated on: Tue, 31 December 2013 01:22]

Report message to a moderator

Re: Passing an collection of data as an input parameter to an procedure and insert them into a table? [message #604460 is a reply to message #604459] Tue, 31 December 2013 01:44 Go to previous messageGo to next message
ashwanth77
Messages: 95
Registered: April 2013
Location: India
Member
i get identifier 'SYS.ODCIVARCHAR2LIST' must be declared
Re: Passing an collection of data as an input parameter to an procedure and insert them into a table? [message #604461 is a reply to message #604460] Tue, 31 December 2013 01:52 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

ALWAYS copy and paste what you do and get as I did it.
Post result of "select * from v$version where rownum=1";

Previous Topic: sql query
Next Topic: Convert date & timestamp into seconds
Goto Forum:
  


Current Time: Fri Apr 19 08:51:00 CDT 2024