我正在尝试从包应用程序Oracle10g中调用存储过程“getGlobalParamValue
org.springframework.boot版本'2.2.0.RELEASE‘
FUNCTION getGlobalParamValue(
pCode VARCHAR2
RETURN INTEGER;当我在SQL developer中运行它时,一切正常,我得到了正确的结果
我试过了
1.
jdbcTemplate.update("BEGIN APP.getGlobalParamValue('base'); END;");或者2.
val sjc = new SimpleJdbcCall(jdbcTemplate)
.withCatalogName("APP")
.withProcedureName("getGlobalParamValue");
sjc.useInParameterNames("pCode")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(new SqlOutParameter("p_out", OracleTypes.INTEGER),
new SqlParameter("pCode", OracleTypes.VARCHAR));
SqlParameterSource in = new MapSqlParameterSource()
.addValue("pCode", "base");
sjc.execute(in);它不能工作
我得到一个错误:
Caused by: org.springframework.jdbc.BadSqlGrammarException:CallableStatementCallback; bad SQL grammar
nested exception is java.sql.SQLException: ORA-06550`发布于 2019-11-01 22:51:10
试试这个:
使用JdbcTemplate的:
int returnResult = jdbcTemplate.queryForObject("SELECT APP.getGlobalParamValue(?) FROM DUAL", new Object[] {pCode});使用EntityManager的:
BigDecimal returnResult = null;
returnResult = (BigDecimal) entityManager.createNativeQuery(
"SELECT APP.getGlobalParamValue(:pCode) FROM DUAL" )
.setParameter("pCode", yourPCode)
.getSingleResult();https://stackoverflow.com/questions/58659148
复制相似问题