oracle| Stored Procedures
Oracle Side
1. Creating Oracle Process Storage
Create or Replace procedure Proce_test (paramin in Varchar2,paramout out varchar2,paraminout into out varchar2)
As
Varparam VARCHAR2 (28);
Begin
Varparam:=paramin;
paramout:=varparam| | Paraminout;
End
2. Test process Storage
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 # Aspect
Referencing 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"; Connecting to a 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 declarations for stored procedures
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 stored procedure name
Cmd.commandtype=commandtype.storedprocedure;
foreach (oracleparameter parameter in parameters)
{
Cmd. Parameters.Add (parameter);
}
Cmd. ExecuteNonQuery ();//Execute stored Procedure
}
}
}
Test results: DDFF