我是Spring jdbcTemplate的新手 我有一个oracle过程,它已经在oracle数据库中编译了
create or replace PROCEDURE TRANSFORM_TRN_AFEES_KVP_PROC(days_to_arch IN number DEFAULT 1)
IS
BEGIN
dbms_output.put_line('START - TRANSFORM_TRN_AFEES_KVP_PROC ');
dbms_output.put_line('Archieving for last '|| days_to_arch || ' days and ' );
INSERT
INTO IP_CO_WR2_USR.TRANSFORM_TRN_AFEES_KVP_ARCH
SELECT *
FROM IP_CO_WR2_USR.TRANSFORM_TRN_AFEES_KVP_TEMP
where insert_timestamp < (CAST (trunc(sysdate-days_to_arch) AS TIMESTAMP));
DELETE
FROM IP_CO_WR2_USR.TRANSFORM_TRN_AFEES_KVP_TEMP
where insert_timestamp < (CAST (trunc(sysdate-days_to_arch) AS TIMESTAMP));
COMMIT ;
DBMS_OUTPUT.PUT_LINE('END - TRANSFORM_TRN_AFEES_KVP_PROC ');
END;
我想使用Spring JdbcTemplate执行此过程,因为您可以看到我不想从此过程返回任何内容!请指导我!
我尝试了其他来源的2或3个解决方案,但他们没有做任何例外而没有工作
第一路
SimpleJdbcCall procReadActor=new SimpleJdbcCall(jdbcTemplate).withProcedureName("TRANSFORM_TRN_AFEES_KVP_PROC");
SqlParameterSource in = new MapSqlParameterSource().addValue("days_to_arch", 3);
Map out = procReadActor.execute(in);
第二路
jdbcTemplate.update("{call TRANSFORM_TRN_AFEES_KVP_PROC (?)}", 3);
第三种方式
Connection connection = jndiDataSource.getConnection();
connection.setAutoCommit(false);
CallableStatement callableStatement = connection.prepareCall("{call TRANSFORM_TRN_AFEES_KVP_PROC(?)}");
callableStatement.setInt(1, 3);
System.out.println(callableStatement.executeUpdate());;
connection.commit();
请指导我写这段代码!