首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-07-29 
动态sql拼接单引号与 变量赋值if (lower(s_table)gl_detail) thenms : select max(ts)from || t_ta

动态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;

热点排行
Bad Request.