Solved

Calling an oracle package procedure with collaction type in parameter

Posted on 2008-10-03
4
626 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now