oracle10g - Using Parameters with Oracle Packages. ODP .NET -
I have an oracle function which returns the record set. I have introduced the parameters for the Oracle function and it is creating front-end code to go to the hardware.
Here is my front-end code.
OracleCommand od = oc.CreateCommand (); Od.CommandType = System.Data.CommandType.Text; Od.CommandText = "Select from table * (pkg_fetchPOInfo.getPorowsTable (: 1 ,: 2))"; //od.CommandText = "pkg_fetchPOInfo.getPORowsTable"; //od.CommandType = System.Data.CommandType.TableDirect; OracleParameter op1 = new OracleParameter (); Op1.ParameterName = "1"; Op1.OracleDbType = OracleDbType.Varchar2; Op1 Direction = System. Data Parameter Direction Input; Op1.Size = 6; Op1.Value = strponumber; Od.Parameters.Add (OP1); OracleParameter op2 = New OracleParameter (); Op2.ParameterName = "2"; Op2.OracleDbType = OracleDbType.Varchar2; Op2 Direction = System. Data Parameter Direction Input; Op2.Size = 3; Op2.Value = "US"; Od.Parameters.Add (op2);
If I execute the query in front-end SQLPLUS, then I get a record. This code works if I remove the parameter from the package and front-end code.
Select * From table (pkg_fetchPOInfo.getPORowsTable ('1007446', 'US')); - Works in SQLPLUS.
Select * From table (pkg_fetchPOInfo.getPORowsTable ()); - Works in both places.
Am I specifying the parameter incorrectly?
Package definition:
Create package test as function testpipe (NR in number, NR2 in number) or go to the pipeline; End test; Prepare or replace package test PP in the form of Prison TestPIPC as a Period of Period Test (number in number, number in NR2 number) and choose Level of Level and Lieutenant; NR .; Vtt varchartabletype; Open BEGIN TESTPIPE_cur; Loop Fetch testpipe_cur bulk Vtt LIMIT assembled in NR2; Vtt.COUNT loop pipeline for indux in 1 (vtt (indx)); End loop; Pass the exam when testpipe_cur% NOTFOUND; End loop; End testpip; End test;
.NET code:
public static zero pipette () {string conString = GetConnectionString (); OracleConnection _conn = new oracle connection (conString); _conn.Open (); Oracle Commands OCMD = New Oracle Commands (); OCmd.CommandText = "Start Open: Select from the table * CRS (testp.testpipe (: nr,: nr2)); end;"; OCmd.CommandType = CommandType.Text; OCmd.Connection = _conn; OracleParameter crs = new OracleParameter (); Crs.OracleDbType = OracleDbType.RefCursor; Crs.Direction = Parameter Direction. Output; Crs.ParameterName = "crs"; OCmd.Parameters.Add (CRS); OracleParameter nr = New OracleParameter (); Nr.OracleDbType = OracleDbType.Int64; Nr. Direction = Parameter Direction. Input; Nr.ParameterName = "nr"; Nr.Value = 25; OCmd.Parameters.Add (NR); OracleParameter nr2 = new Oracle parameter (); Nr2.OracleDbType = OracleDbType.Int64; Nr2. Direction = Parameter Direction. Input; Nr2.ParameterName = "nr2"; Nr2.Value = 10; OCmd.Parameters.Add (NR2); (Using OracleDataReader MyReader = oCmd.ExecuteReader ()) {int columnCount = MyReader.FieldCount; // Get data and add row (MyReader.Read ()) {string s = MyReader.GetOracleValue (0) .ToString (); Console.light line (string.format ("I = {0}", s)); }} Console. Readline (); }
Comments
Post a Comment