C # retrieve Oracle Functions

Source: Internet
Author: User
# Region Extract Function
String soraconnection = "Data Source = sh2.chs. cyw.rik. com; persist Security info = true; user id = Doc; Password = ***; Unicode = true ";

///   <Summary>
/// Method 2 for retrieving a function from a table
///   </Summary>
Private   Void Connecctoraclefunctiontwo ()
{
Oracleconnection occonnection =   New Oracleconnection (soraconnection );
Oraclecommand occommand = Occonnection. createcommand ();
Occommand. commandtext =   " Doc. get_dm_object " ;
Occommand. commandtype = Commandtype. storedprocedure;

Occommand. Parameters. Add ("V_id", Oracletype. number );

// Note: The name must be consistent with that in PLSQL; otherwise, it is incorrect.
// Value of the number of incoming records
Occommand. Parameters [ " V_id " ]. Value =   83 ;
Occommand. Parameters [ " V_id " ]. Direction = Parameterdirection. input;

Occommand. Parameters. Add ("V_name", Oracletype. varchar,200);
Occommand. Parameters ["V_name"]. Direction=Parameterdirection. returnvalue;

Try
{
Occonnection. open ();
Occommand. executeoraclescalar ();
String Strret = Occommand. Parameters [ " V_name " ]. Value. tostring ();
RTB. Text = Strret;
}
Catch (Exception ex)
{

ThrowEx;
}
}

///   <Summary>
/// Method 1 for retrieving a function from a table
///   </Summary>
Private   Void Conneoracleoraclefunctionone ()
{
Oracleconnection occonnection =   New Oracleconnection (soraconnection );
Oraclecommand occommand = Occonnection. createcommand ();
Occommand. commandtext =   " Select Doc. get_dm_object (: dob_id) from dm_object " ;
Occommand. Parameters. Add ( " Dob_id " , Oracletype. number );
// Value of the number of incoming records
Occommand. Parameters [ " Dob_id " ]. Value =   83 ;
Occommand. Parameters [ " Dob_id " ]. Direction = Parameterdirection. input;
Try
{
Occonnection. open ();
String Strret = Occommand. executeoraclescalar (). tostring ();
RTB. Text = Strret;
}
Catch (Exception ex)
{

ThrowEx;
}
}

# Endregion

/* Function used by the consumer

* Create or replace function get_dm_object (v_id dm_object.id % type)
* Return dm_object.name % Type
*
* V_name dm_object.name % type;
* Begin
* Select name into v_name
* From dm_object
* Where id = v_id;
* Return v_name;
* Exception when no_data_found
* Then return '';
* End;
*/

*/

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.