当前位置: 代码迷 >> SQL >> 动态sql拼凑单引号与 变量赋值
  详细解决方案

动态sql拼凑单引号与 变量赋值

热度:60   发布时间:2016-05-05 15:15:06.0
动态sql拼接单引号与 变量赋值
if (lower(s_table)='gl_detail') then      ms := 'select max(ts)  from ' || t_table;    --给变量赋值     execute immediate ms  into max_ts;     --添加单引号     max_ts := ''''||max_ts||'''';     step_one_sql := 'delete from ' || t_table || ' where '|| pk_field || ' in (select ' || pk_field || ' from ' || s_table || ' where  '|| s_ts ||'>'||max_ts||')';        DBMS_OUTPUT.PUT_LINE(step_one_sql);             step_three_sql := 'insert into ' || t_table || ' select * from ' || s_table || ' where ' || s_ts;   step_three_sql := step_three_sql || ' >'||max_ts;
  相关解决方案