Oracle
1. Create an Oracle Stored Procedure
Create or replace procedure proce_test (paramin in varchar2, paramout out varchar2, paraminout in out varchar2)
As
Varparam varchar2 (28 );
Begin
Varparam: = paramin;
Paramout: = varparam | paraminout;
End;
2. Test the Stored Procedure
Declare
Param_out varchar2 (28 );
Param_inout varchar2 (28 );
Begin
Param_inout: = ff;
Proce_test (dd, param_out, param_inout );
Dbms_output.put_line (param_out );
End;
C #
Reference Oracle components
Using System;
Using System. Data;
Using System. Data. OracleClient;
Namespace WebApplication4
{
Public class OraOprater
{
Private OracleConnection conn = null;
Private OracleCommand cmd = null;
Public OraOprater ()
{
String mConn = "data source = ora9i.ora.com; user id = ora; password = ora"; // connect to the database
Conn = new OracleConnection (mConn );
Try
{
Conn. Open ();
Cmd = new OracleCommand ();
Cmd. Connection = conn;
}
Catch (Exception e)
{
Throw e;
}
}
Public string SpExeFor (string m_A, string m_ B)
{
// Parameter declaration of Stored Procedure
OracleParameter [] parameters = {
New OracleParameter ("paramin", OracleType. VarChar, 20 ),
New OracleParameter ("paramout", OracleType. VarChar, 20 ),
New OracleParameter ("paraminout", OracleType. VarChar, 20)
};
Parameters [0]. Value = m_A;
Parameters [2]. Value = m_ B;
Parameters [0]. Direction = ParameterDirection. Input;
Parameters [1]. Direction = ParameterDirection. Output;
Parameters [2]. Direction = ParameterDirection. InputOutput;
Try
{
RunProcedure ("proce_test", parameters );
Return parameters [1]. Value. ToString ();
}
Catch (Exception e)
{
Throw e;
}
}
Private void RunProcedure (string storedProcName, OracleParameter [] parameters)
{
Cmd. CommandText = storedProcName; // declare the name of the stored procedure
Cmd. CommandType = CommandType. StoredProcedure;
Foreach (OracleParameter parameter in parameters)
{
Cmd. Parameters. Add (parameter );
}
Cmd. ExecuteNonQuery (); // execute the Stored Procedure
}
}
}
Test result: ddff