Solved

Calling an oracle package procedure with collaction type in parameter

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database

776 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