Stored procedures Use the Db.execute (Icallback) method, in which you use:
Connection.preparecall (SQL). Execute ();
You can call the stored procedure, and you can also control the return value freely
Example:
Public Boolean setvarvalue (final string processinstanceid, final string varName, final string varvalue) {
Boolean flag = false;
Object o = Db.execute (new Icallback () {
@Override
Public Boolean Call (Connection conn) throws SQLException {
Boolean flag = false;
try {
callablestatement proc = Conn.preparecall ("{Call Process_warn.set_var_value (?,?,?)}");
Proc.setstring (1, Processinstanceid);
Proc.setstring (2, varName);;
Proc.setstring (3, varvalue);
Proc.execute ();
The code comes here to show that your stored procedure has been successfully called, and if there are output parameters, then the process of taking out the output parameters
Flag = true;
} catch (Exception e) {
Flag = false;
Log.error ("EXECUTE procedure process_warn.set_var_value mistakes!!!");
E.printstacktrace ();
}
return flag;
}
});
Flag = (Boolean) o;
return flag;
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、
With a return value.
public string activetaskforupdate (final string Processinstanceid,
Final string Operationclasskey, final string operationkey, final string taskorgid,
Final string Orgfilterid, final string othertag,final string newType) {
String task_id_list = "";
Object o = Db.execute (new Icallback () {
@Override
Public String Call (Connection conn) throws SQLException {
String task_id_list = "";
try {
callablestatement proc = Conn.preparecall ("{Call Process_warn.active_task_for_update (?,?,?,?,?,?,?,?)}");
Proc.setstring (1, Processinstanceid);
Proc.setstring (2,operationclasskey);
Proc.setstring (3, Operationkey);
Proc.setstring (4, Taskorgid);
Proc.setstring (5, Orgfilterid);
Proc.setstring (6, Othertag);
Proc.setstring (7, NewType);
Proc.registeroutparameter (8, Oracle.jdbc.OracleTypes.VARCHAR);
Proc.execute ();
The code comes here to show that your stored procedure has been successfully called, and if there are output parameters, then the process of taking out the output parameters
Task_id_list = Proc.getobject (8). toString ();
} catch (Exception e) {
Log.error ("EXECUTE procedure process_warn.active_task_for_updatemistakes!!!");
E.printstacktrace ();
if (E.getmessage (). IndexOf ("ORA-20012")! =-1) {
String msg = E.getmessage (). Split ("#") [1];
throw new Noassigneeexception (msg);
}else{
throw new Systemunknownexception (E.getmessage ());
}
}
return task_id_list;
}
});
Task_id_list = (String) o;
return task_id_list;
}
Jfinal How do I invoke an Oracle stored procedure?