Solved

Calling an oracle package procedure with collaction type in parameter

Posted on 2008-10-03
4
630 Views
Last Modified: 2013-12-18
I have a VB.NET project. I have to call a procedure, wich has an input parameter of collection type. I need a VB.NET code, wich first fills this special input parameter, than calls the procedure.

The PL/SQL code:

create or replace package LZ_PROBA is

   type r_record is record (field1 number, field2 varchar2(3));
   type t_tabparam is table of r_record index by varchar2(3);
   
   procedure proc(i_param in t_tabparam);

end LZ_PROBA;


Thanks.
0
Comment
Question by:ZLenart
  • 3
4 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 22637027
0
 
LVL 21

Expert Comment

by:oleggold
ID: 22637050
It seems You'll need ref cursor here anyway so I'd use this example from the link above:
"VB.Net Example wrote:

'' Via a C#->VB.Net Converter, Your Milage May Vary
Dim conn As New OracleConnection("User Id=scott;Password=tiger;Data Source=oracle")
Dim cmd = New OracleCOmmand("MyPackage.InsertNote", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(":p_NoteTitle", OracleDbType.Varchar2, 50)
cmd.Parameters.Add(":p_NoteText", OracleDbType.Varchar2, 2000)

Dim titles As [String]() =  {"Shopping List", "Todo List", "Little Black Book"}
Dim Notes As [String]() =  { _
"Eggs, Milk, Bread, 10 gal of Everclear", _
"Create World Peace, Solve Hunger & Poverty, Write Great American Novel", _
"Anna 555-5555," + ControlChars.Cr + ControlChars.Lf + "Susan 222-2222," + ControlChars.Cr + ControlChars.Lf + "Fred 999-9999" _
}

cmd.ArrayBindCount = 3

cmd.Parameters(":p_NoteTitle").Value = titles
cmd.Parameters(":p_NoteText").Value = Notes

Try
     conn.Open()
     cmd.ExecuteNonQuery()
Finally
   conn.Close()
   conn.Dispose()
End Try"
0
 
LVL 21

Accepted Solution

by:
oleggold earned 500 total points
ID: 22637057
sorry,as code
VB.Net Example wrote:
 
'' Via a C#->VB.Net Converter, Your Milage May Vary
Dim conn As New OracleConnection("User Id=scott;Password=tiger;Data Source=oracle")
Dim cmd = New OracleCOmmand("MyPackage.InsertNote", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(":p_NoteTitle", OracleDbType.Varchar2, 50)
cmd.Parameters.Add(":p_NoteText", OracleDbType.Varchar2, 2000)
 
Dim titles As [String]() =  {"Shopping List", "Todo List", "Little Black Book"}
Dim Notes As [String]() =  { _ 
"Eggs, Milk, Bread, 10 gal of Everclear", _ 
"Create World Peace, Solve Hunger & Poverty, Write Great American Novel", _ 
"Anna 555-5555," + ControlChars.Cr + ControlChars.Lf + "Susan 222-2222," + ControlChars.Cr + ControlChars.Lf + "Fred 999-9999" _ 
}
 
cmd.ArrayBindCount = 3
 
cmd.Parameters(":p_NoteTitle").Value = titles 
cmd.Parameters(":p_NoteText").Value = Notes 
 
Try
     conn.Open()
     cmd.ExecuteNonQuery()
Finally
   conn.Close()
   conn.Dispose()
End Try

Open in new window

0
 

Author Closing Comment

by:ZLenart
ID: 31502714
Thanks oleggold!

It helped me very much.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question