How Oracle returns a result set in a stored procedure

Source: Internet
Author: User

There are a number of different Oracle and SQL Server locations.

Personal deepest experience is that the stored procedure returns the result set, and the direct select query in SQL Server is OK, Oracle is not.

Here, we use the simplest example to illustrate the example of a stored procedure returning a result set.
CREATE OR REPLACE PROCEDUREStored Procedure name (field nameinch VARCHAR2,L_result out TYPES. Rq_ref_cursor--the method name inside the package) isStr_sqlvarchar2(8000) := "'; beginStr_sql:='SELECT * from Tabelname where id='||Field name;
OpenL_result forStr_sql;
ENDRegion_linkage;
Create package (not required)
CREATE OR REPLACE  as  isCURSOR; END;

Creating a package is not necessary, adding the REF CURSOR directly after the OUT keyword of the stored procedure can also

In addition, the general method of calling stored procedures in C # is added
 PublicDataTable Insertt_builditem (stringregion_id) {DataSet DS=NewDataSet (); Try        {            stringsql ="Stored Procedure name"; OracleConnection Con= This. _sqlcon; OracleCommand cmd=Neworaclecommand (sql, con); Cmd.commandtype=CommandType.StoredProcedure; The declaration is a stored procedure cmd. Parameters.Add ("Incoming parameter name", Oracletype.nvarchar). Value =region_id; Cmd. Parameters.Add ("the name of the cursor returned", OracleType.Cursor). Direction =ParameterDirection.Output; OracleDataAdapter AD=NewOracleDataAdapter (CMD); Ad. Fill (DS,"Report_build"); }        Catch(Exception e) {Throwe; }        returnDs. tables[0]; }
Related documents

Oracle Video Tutorial: Http://oracle.so138.com/video

Oracle Beginner's Tutorial: http://www.cnblogs.com/linjiqin/category/349944.html

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.