Table numbervarchar2 (tenvarchar2 (4 numbervarchar2);
2. Create a stored procedure with no parameters
CreateOr replace procedureisbegin insert Span style= "color: #0000ff;" >into Test (id,name,sex,age) (1, ' moses '
3. Write C # code to call this stored procedure with no parameters
protected void button2_click (object sender, EventArgs e) {String OC = configurationmanager.connectionstrings[ "conn" ]. ToString (); OracleConnection conn = new OracleConnection (OC); Conn. Open (); OracleCommand orm = Conn. CreateCommand (); Orm. CommandType = CommandType.StoredProcedure; Orm. CommandText = "proc1; Orm. ExecuteNonQuery (); Conn. Close (); }
4. Write a stored procedure with parameters that do not have a return value
Replace proc2 (v_id number varchar2)into test (id,name)values(v_id,v_name); Commit; End; /
5.c# calls this stored procedure with no return value for the parameter
Protectedvoid Button1_Click (Objectsender, EventArgs e) {if (String. IsNullOrEmpty (This. TextBox2.Text)) {This. TextBox2.Text ="The number cannot be empty";This. Textbox2.focus ();Return; }if (String. IsNullOrEmpty (This. TextBox3.Text)) {This. TextBox3.Text ="The name cannot be empty";This. Textbox3.focus ();Return; } String or=configurationmanager.connectionstrings["Conn"]. ToString (); OracleConnection OC =NewOracleConnection (or); Oc. Open (); OracleCommand om =Oc. CreateCommand (); Om.commandtype =CommandType.StoredProcedure; Om.commandtext ="Proc2"; Om. Parameters.Add ( "v_id" Oracletype.number). Direction = ParameterDirection.Input; om. Parameters[ "v_id"]. Value = this "v_name ParameterDirection.Input; om. Parameters[ "v_name"] . Value = this
6. Write a stored procedure with a parameter with a return value
Number)begincount (from test; Commit; End; /
7.c# calls this stored procedure with a return value with a parameter
Protectedvoid Button1_Click (Objectsender, EventArgs e) {String or = configurationmanager.connectionstrings["Conn"]. ToString (); OracleConnection OC =new OracleConnection (or); OC. Open (); OracleCommand ocm = OC. CreateCommand (); ocm. CommandType = CommandType.StoredProcedure; ocm. CommandText = "proc3; ocm. Parameters.Add ( "reccount ParameterDirection.Output; ocm. ExecuteNonQuery (); this. TextBox1.Text = ocm. Parameters[ "reccount "". Value.tostring (); }
C # calls Oracle stored procedure "reproduced"