The DataDirect provider for Oracle calls The stored procedure using The Cursor type parameter

Source: Internet
Author: User

When executing a stored procedure that returns a ref cursor parameter, the Microsoft Oracle provider requires that the ref cursor be bound as an OracleParameter object of type OracleDbType. Cursor.

The DataDirect provider for Oracle does not require these parameters to be bound at all. the DataDirect provider returns the results from REF CURSORs as a result set from the stored procedure, either through an OracleDataReader returned from OracleCommand. executeReader
Or through an OracleDataAdapter.

This provides for easier coding as you do not need to do anything for REF CURSORs to be returned to the application. it also provides additional interoperability wait SS providers as result sets from stored procedures are returned in the same manner with all
Of the DataDirect providers.

If multiple REF CURSORs are returned, then the DataDirect Oracle provider returns them as multiple result sets in the order of the ref cursor parameters in the Create Procedure statement. therefore, you shoshould simply remove the bindings for any parameters
This type.

The following code example creates a stored procedure and ref cursor on the Oracle server:

create or replace package EMP_PACKAGE ASTYPE EmpCurType IS REF CURSOR RETURN emp%ROWTYPE;END EMP_PACKAGE;create or replace procedure empcursor (emp_cv IN OUTEMP_PACKAGE.EmpCurType,salary IN NUMBER)asBEGINOPEN emp_cv FOR SELECT * FROM emp WHERE sal > salary;END;

Thus a statement in the Microsoft Oracle provider wocould need to be changed from:

OracleCommand DBCmd = new OracleCommand("empcursor", DBConn);DBCmd.CommandType = CommandType.StoredProcedure;DBCmd.Parameters.Add("emp_cv", OracleType.Cursor).Direction= ParameterDirection.Output;DBCmd.Parameters.Add ("salary", OracleType.Number,15,"").Value = 30000;OracleDataReader myDataReader;myDataReader = DBCmd.ExecuteReader();

To:

OracleCommand DBCmd = new OracleCommand("empcursor", DBConn);DBCmd.CommandType = CommandType.StoredProcedure;DBCmd.Parameters.Add ("anyname", OracleDbType.Number,15,"").Value = 30000;OracleDataReader myDataReader;myDataReader = DBCmd.ExecuteReader();

Note that in the above example, only the second parameter in the stored procedure ("salary") is bound to the DataDirect Oracle provider.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.