本人想写一个oracle数据库存储过程,但其中有一段需要插入特定表的代码,如下所示:insert into bill_batch_operation_record_t20080629 
select distinct * from ls6_bill.bill_batch_operation_record_t@ysdb where acct_id in(
select acct_id from bill.change_charge_record_t cct where cct.qu_order=str_qu_order
);
表名bill_batch_operation_record_t20080629后面的日期必须取前天的日期,每天动态改变,请问哪位高人可以帮我一个忙啊,小弟不胜感激

解决方案 »

  1.   

    你的表是每天建的?
    用动态SQL先拼出语句,然后动态执行
      

  2.   

    begin
      temp_sql:='insert into bill_batch_operation_record_t'||to_char(sysdate-1,'yyyymmdd')||' 
    select distinct * from ls6_bill.bill_batch_operation_record_t@ysdb where acct_id in( 
    select acct_id from bill.change_charge_record_t cct where cct.qu_order=str_qu_order 
    )';
      execute immediate temp_sql;