使用Java PL / SQL删除超过3天的表

时间:2014-04-22 07:08:05

标签: plsql

对于以下PL / SQL语句 查询删除10天之前的表

String s = "begin
    for xx in ( select tableName from ALLTABLES where regexp_like(tableName, '  ABCD[[:digit:]]{8}'  ) and to_date(substr(tableName, -8), ' yyyymmdd' ) <  trunc(sysdate) - 3) 
    loop
    execute immediate ' drop table'  ||xx.tableName ||'  purge'  ;
    end loop;
    end;"

我正在使用Callablestatement

CallableStatement cs = null;
cs = conn.prepareCall(s);
cs.execute(rplSql);

但这似乎显示无效的SQL语句,任何想法??

1 个答案:

答案 0 :(得分:0)

尝试:

select table_Name from ALL_TABLES where regexp_like(table_Name, '  ABCD[[:digit:]]{8}')

in for statement