Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling an oracle package procedure with collaction type in parameter

Posted on 2008-10-03
4
Medium Priority
?
637 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: 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

971 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