大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國(guó)咨詢/投訴熱線:400-8080-105
動(dòng)力節(jié)點(diǎn)LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁(yè) hot資訊 Oracle動(dòng)態(tài)SQL拼接

Oracle動(dòng)態(tài)SQL拼接

更新時(shí)間:2021-11-08 12:54:06 來(lái)源:動(dòng)力節(jié)點(diǎn) 瀏覽1281次

1. 直接用單引號(hào),單引號(hào)的使用是就近配對(duì),即就近原則。從第二個(gè)單引號(hào)開(kāi)始被視為轉(zhuǎn)義符

v_sql := ' insert into  BJTONGRENTANGTEMPTB  select distinct h.sellerid,h.sellercode,h.sellername,h.prodcode,h.prodname from historyofsales_day h '
||' where h.sellerid in (select distinct ovalorgid from bjtongrentangpc ) '
||' and h.prodcode in (select prodcode from buproduct where bucode= '''||v_bucode||''')'
||' and to_char(h.salesdate,''yyyyMM'') =''' || v_year||v_month||'''';
if v_productcode is not null then
  v_sql := v_sql || ' and h.prodcode = '''||v_productcode||'''';
end if;
if v_seller is not null then
  v_sql := v_sql || ' and h.sellername like ''%'||v_seller||'%''';
end if;
if v_provincecode is not null then
  v_sql := v_sql || ' and h.buyerprovincecode = '''||v_provincecode||'''';
end if;
if v_productspec is not null then
  v_sql := v_sql || ' and h.prodspec like ''%'||v_productspec||'%''';
end if;
execute immediate v_sql;
commit;

2. 利用chr(39)轉(zhuǎn)義單引號(hào)

v_sql := ' insert into  BJTONGRENTANGTEMPTB  select distinct h.sellerid,h.sellercode,h.sellername,h.prodcode,h.prodname from historyofsales_day h '
||' where h.sellerid in (select distinct ovalorgid from bjtongrentangpc ) '
||' and h.prodcode in (select prodcode from buproduct where bucode= '||chr(39)||v_bucode||chr(39)||')'
||' and to_char(h.salesdate,''yyyyMM'') =' ||chr(39)|| v_year||v_month||chr(39);
if v_productcode is not null then
  v_sql := v_sql || ' and h.prodcode = '||chr(39)||v_productcode||chr(39);
end if;
if v_seller is not null then
  v_sql := v_sql || ' and h.sellername like '||chr(39)||'%'||v_seller||'%'||chr(39);
end if;
if p_provincename is not null then
  v_sql := v_sql || ' and h.buyerprovincename = '||chr(39)||p_provincename||chr(39);
end if;
if v_productspec is not null then
  v_sql := v_sql || ' and h.prodspec like '||chr(39)||'%'||v_productspec||'%'||chr(39);
end if;

3. 利用execute immediate using占位符語(yǔ)法處理

v_sql := ' insert into  BJTONGRENTANGTEMPTB  select distinct h.sellerid,h.sellercode,h.sellername,h.prodcode,h.prodname from historyofsales_day h '
||' where h.sellerid in (select distinct ovalorgid from bjtongrentangpc ) '
||' and h.prodcode in (select prodcode from buproduct where bucode= :1)'
--||' and to_char(h.salesdate,''yyyyMM'') =:2:3';
||' and to_char(h.salesdate,''yyyy'') =:2';
--execute immediate v_sql using v_bucode,v_year,v_month; --error  ORA-01006:綁定變量不存在
execute immediate v_sql using v_bucode,v_year;
commit;

4. 其他的

select q'[it's a cat]' from dual;

如果大家想了解更多相關(guān)知識(shí),可以來(lái)關(guān)注一下動(dòng)力節(jié)點(diǎn)的Oracle教程,里面的內(nèi)容詳細(xì),通俗易懂,適合小白學(xué)習(xí)。

提交申請(qǐng)后,顧問(wèn)老師會(huì)電話與您溝通安排學(xué)習(xí)

  • 全國(guó)校區(qū) 2025-04-24 搶座中
  • 全國(guó)校區(qū) 2025-05-15 搶座中
  • 全國(guó)校區(qū) 2025-06-05 搶座中
  • 全國(guó)校區(qū) 2025-06-26 搶座中
免費(fèi)課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 精品中文字幕在线 | 99精品在线免费 | 视频在线亚洲 | 亚洲国产精品高清在线一区 | 色婷婷色综合 | 色88888久久久久久影院 | 色综合合久久天天综合绕视看 | 亚洲精品福利一区二区 | 亚洲日本欧美产综合在线 | 男女生性毛片免费观看 | 久久久久久久久久爱 | 一级成人毛片免费观看 | 99久久国产综合精麻豆 | 亚洲最大激情中文字幕 | 国产精品18久久久久久小说 | 国产情侣普通话刺激对白 | 国产一区精品视频 | 日韩中文字幕在线有码视频网 | 综合在线视频 | 99视频在线国产 | 欧洲a级毛片 | 99热久久这里只精品国产ww | 日韩毛片久久91 | 久久精品久久精品 | 国产在线拍国产拍拍偷 | 国产亚洲精品美女 | 国内精品久久久久久影院网站小说 | 91模特 | 精品国产综合区久久久久99 | 奇米四色在线观看 | 精品久久久中文字幕二区 | 亚洲色综合 | 成年黄网站免费大全毛片 | 日本成人毛片 | 奇米视频777 | 免费可以直接观看的毛片 | 黄色一级免费网站 | 久在线精品视频 | 欧美日韩一区二区综合在线视频 | 日本热久久 | 香蕉国产在线 |