C # Calling Stored Procedure Methods with parameters-Oracle

Source: Internet
Author: User

1Because the eight reports of the crosstab chart are written inSQL.SQLStatement has300The view cannot be defined because there are too many rows. Because a parameter must be passed, the stored procedure is used.

 

First, define the package, and then define the package body.. NetCall to generate a dataset

. NetCallOracleThe stored procedure with parameters returns the dataset.

OracleThe steps are as follows:

InPL/SQLFirst write the definition file of the package

Create or replace package zhbb
Type t_cursor is ref cursor;
Procedure zh11 (RQ in char, io_cursor in out t_cursor );

Procedure zh12 (RQ in char, io_cursor in out t_cursor );

End zhbb;

Next, write the definition file of the package body.

Create or replace package body zhbb

Procedure zh11 (RQ in char, io_cursor in out t_cursor) is

V_cursor t_cursor;

Begin

Open v_cursor

Select * from AA where Ny = RQ;

Io_cursor: = v_cursor;

End zh11;

Procedure zh12 (RQ in char, io_cursor in out t_cursor) is

.....

End zh12;

. NetCall method:

Public StaticDatatable getdatatable (StringPackagename,StringProname,StringConnstring,StringRQ)

{

Connstring ="Provider = msdaora.1; user id = xx; Data Source = xx; Password = xx;"

 //Define the new link method, because the original driver"Oraoledb. Oracle"Cannot meet requirements, set"Msdaora.1"

Oledbconnection oraclecon =NewOledbconnection (connstring );

Oraclecon. open ();

Oledbcommand cmd =NewOledbcommand ("{call" + packagename + "." + proname + "(?, {Resultset 0, io_cursor})} ", oraclecon );

Cmd. Connection = oraclecon;

Cmd. Parameters. Add ("RQ", oledbtype. varchar, 8). value = "" + RQ + "";

Oledbdataadapter da =NewOledbdataadapter (CMD );

Datatable dt =NewDatatable ();

// Dataset DS = new dataset ();

Da. Fill (DT );

Oraclecon. Close ();

Oraclecon. Dispose ();

ReturnDT;

}

}

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.