Solved

Calling an oracle package procedure with collaction type in parameter

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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 how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
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

867 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

21 Experts available now in Live!

Get 1:1 Help Now