当前位置: 代码迷 >> SQL >> sql 存储过程 for in loop 施用 业务
  详细解决方案

sql 存储过程 for in loop 施用 业务

热度:694   发布时间:2016-05-05 13:45:59.0
sql 存储过程 for in loop 使用 业务
declare begin for tttt in  (select temp.c_id                   from (select cst.c_tci_id, max(ins.T_END_DATE) as endDate                           from tb_test_1 t1, tb_test_2 t2                          where t1.c_id = t2.c_id                            and t1.C_DEL = '0'                            group by c_tci_id) temp                  where endDate < sysdate)      loop           update tb_test_1 t1              set t1.c_stat ='0'            where t1.c_id = tttt.c_id;            --commit;      end loop;      end;--declare begin for thecst in  (select temp.c_tci_id                   from (select cst.c_tci_id, max(ins.T_END_DATE) as insDate                           from tb_test1 cst, tb_test2 ins                          where cst.c_tci_id = ins.c_cst_id                            and cst.C_DEL = '0'                            --and cst.c_stat = '0'                            and cst.C_NO_RELEASE = '1'                             and ins.C_DEL = '0'                            and ins.c_stat is null                            and ins.c_is_telesale_ply is null                            group by c_tci_id) temp                   where insDate < sysdate                    and  temp.c_tci_id not in                    (select cst.c_tci_id                                from tb_cst_info cst, tb_ins_info ins                               where cst.c_tci_id = ins.c_cst_id                                )                  )      loop           update tb_test1 cst              set cst.C_NO_RELEASE = '0',cst.T_NO_RELEASE_TIME = sysdate, cst.c_stat ='0'            where cst.c_tci_id = thecst.c_tci_id;            --commit;      end loop;      end;
  相关解决方案