我正在尝试从包应用程序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:44:06
对于我来说,获得原始类型的结果是有效的
val sql = "select APP.getGlobalParamValue('baseAirport') from dual";
val seq = jdbcTemplate.queryForObject(sql, new Object[] {}, Long.class);我找到了一个例子,很有趣的https://github.com/spring-projects/spring-integration-samples/tree/master/intermediate/stored-procedures-oracle
发布于 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();发布于 2019-11-01 22:58:36
对我来说,获取数据集作为结果是可行的
jdbcTemplate.query("select * from table(MYPACKAGE.getrows(21861, 6793, 1829,57464))",(ResultSet rs)->{
while(rs.next()){
System.out.println(rs.getInt("ID"));
}
});https://stackoverflow.com/questions/58659148
复制相似问题