3,499
社区成员
发帖
与我相关
我的任务
分享
public int moveData(final String tableName) throws Exception {
// TODO Auto-generated method stub
String sql = "{call move_ccodepool_table_poppy(?,?)}";
Object o = super.execute(sql, new CallableStatementCallback() {
public Object doInCallableStatement(CallableStatement cs)
throws SQLException, DataAccessException {
// TODO Auto-generated method stub
cs.setString(1, tableName);
cs.executeUpdate();
int a = cs.getInt(2);
return a;
}
});
if (o != null) {
return (Integer) o;
}
return 0;
}
create or replace procedure move_ccodepool_table_poppy(tableName IN VARCHAR,
rowCnt out int) as
v_sql varchar2(500); --sql语句
v_sql1 varchar2(500);
begin
v_sql := 'delete from ' || tableName ||
' where cpp_status != 0 or ent_time < sysdate';
dbms_output.put_line('rows deleted' || sql%rowcount);
v_sql1 := 'insert into t_c_code_pool_Bak (ccp_id, cg_id, cpp_usecount, cpp_img, cpp_number, cpp_status, used_count, start_time, ent_time, ccp_stringkey, BAK_TIME
) select t.ccp_id, t.cg_id, t.cpp_usecount, t.cpp_img, t.cpp_number, t.cpp_status, t.used_count, t.start_time, t.ent_time, t.ccp_stringkey, sysdate
from ' || tableName ||
' t where t.cpp_status != 0 or t.ent_time < sysdate';
execute immediate v_sql1;
execute immediate v_sql;
rowCnt :=sql%rowcount;
commit;
end;