我已经使用spring和procedure使用Simplejdbccall成功保存了详细信息但是我需要从procedure返回一个值并在java代码中获取它
这是java代码
public void saveNamedDrivers(QuotationDO quotationDO) {
// TODO Auto-generated method stub
try {
System.out.println(" 11111");
SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(dataSource);
simpleJdbcCall.withCatalogName("NAMED_DRIVER_SAVE").withProcedureName("PR_NAMED_DRIVER_SAVE")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(new SqlParameter("P_VCH_NAME", OracleTypes.VARCHAR),
new SqlParameter("P_NUM_NEW_IC_NO", OracleTypes.VARCHAR),
new SqlParameter("P_NUM_OLD_IC_NO", OracleTypes.VARCHAR),
new SqlParameter("P_VCH_GENDER", OracleTypes.VARCHAR),
new SqlParameter("P_VCH_RELATIONSHIP", OracleTypes.VARCHAR),
new SqlParameter("P_NUM_AGE", OracleTypes.NUMBER),
new SqlParameter("P_VCH_DRIVER_EXPERIENCE", OracleTypes.VARCHAR));
SqlParameterSource inputParams = new MapSqlParameterSource()
.addValue("P_VCH_NAME", quotationDO.getNameddrivername())
.addValue("P_NUM_NEW_IC_NO", quotationDO.getNamednewicno())
.addValue("P_NUM_OLD_IC_NO", quotationDO.getNamedoldicno())
.addValue("P_VCH_GENDER", quotationDO.getNamedgender())
.addValue("P_VCH_RELATIONSHIP", quotationDO.getNameddriverrelationship())
.addValue("P_NUM_AGE", quotationDO.getNamedage())
.addValue("P_VCH_DRIVER_EXPERIENCE", quotationDO.getNameddriverexperience());
Map<String, Object> transactionStatus = simpleJdbcCall.execute(inputParams);
System.out.println( transactionStatus);
} catch (Exception e) {
System.out.println(e);
}
}
如何更改过程和java代码以从过程中获取值
Sql程序
CREATE OR REPLACE PACKAGE BODY SYSTEM.NAMED_DRIVER_SAVE AS PROCEDURE
PR_NAMED_DRIVER_SAVE (
P_VCH_NAME VARCHAR2,
P_NUM_NEW_IC_NO VARCHAR2,
P_NUM_OLD_IC_NO VARCHAR2,
P_VCH_GENDER VARCHAR2,
P_VCH_RELATIONSHIP VARCHAR2,
P_NUM_AGE NUMBER,
P_VCH_DRIVER_EXPERIENCE VARCHAR2
) as
P_NAMED_ID NUMBER;
BEGIN
BEGIN P_NAMED_ID := 0;
SELECT SEQ_NAMED.NEXTVAL INTO P_NAMED_ID FROM DUAL;
END;
BEGIN
INSERT INTO EIS_TRN_NAMED_DRIVERS (
NUM_S_NO,
VCH_NAME,
NUM_NEW_IC_NO,
NUM_OLD_IC_NO,
VCH_GENDER,
VCH_RELATIONSHIP,
NUM_AGE,
VCH_DRIVER_EXPERIENCE
)VALUES(
P_NAMED_ID,
P_VCH_NAME,
P_NUM_NEW_IC_NO,
P_NUM_OLD_IC_NO,
P_VCH_GENDER,
P_VCH_RELATIONSHIP,
P_NUM_AGE,
P_VCH_DRIVER_EXPERIENCE
);
COMMIT;
EXCEPTION WHEN OTHERS THEN RAISE;
end;
DBMS_OUTPUT.put_line(P_NUM_AGE);
RETURN;
END PR_NAMED_DRIVER_SAVE;
END NAMED_DRIVER_SAVE;
/
[我使用DBMS_OUTPUT.put_line(P_NAMED_ID);
在debbuging sql过程中输出了输出,但是如何在上面的java代码中获取它
] Image