在Oracle數據庫中,可以使用以下方法來調用存儲過程:
DECLARE
result VARCHAR2(50);
BEGIN
stored_procedure_name(parameter1, parameter2, ..., result);
DBMS_OUTPUT.PUT_LINE(result);
END;
BEGIN
stored_procedure_name(parameter1, parameter2, ...);
END;
CallableStatement cstmt = connection.prepareCall("{call stored_procedure_name(?, ?)}");
cstmt.setString(1, parameter1);
cstmt.setString(2, parameter2);
cstmt.execute();
CallableStatement cstmt = connection.prepareCall("{call stored_procedure_name(?, ?, ?)}");
cstmt.setString(1, parameter1);
cstmt.setString(2, parameter2);
cstmt.registerOutParameter(3, Types.VARCHAR);
cstmt.execute();
String result = cstmt.getString(3);