大战熟女丰满人妻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ù)文檔推薦 >>
主站蜘蛛池模板: 毛片色| 国产精品96久久久久久久 | 可以免费观看欧美一级毛片 | 99j久久精品久久久久久 | 免费毛片播放 | a级精品九九九大片免费看 a级毛片高清免费视频 | 亚洲综合一区二区三区 | 自拍亚洲午夜伦li片影院 | a大片久久爱一级 | 亚洲日本在线观看视频 | 国产高清在线精品 | 男人与牛做爰的视频 | 欧美久草 | 欧美乱插 | 伊人久久大香焦 | 亚洲一区在线视频观看 | 九热在线 | 国产精品美女久久久久 | 国产你懂得 | 日日夜夜综合 | 日韩精品中文字幕一区三区 | 久久综合给合久久97色美利坚 | 久久亚洲综合中文字幕 | 在线播放国产一区二区三区 | 色偷偷青青草原在线视频 | 亚洲国产高清精品线久久 | 香蕉久久夜色精品国产小说 | 性成人动作片在线看 | 国产久爱青草视频在线观看 | 天天综合天天看夜夜添狠狠玩 | 国产一级特黄特色aa毛片 | 婷婷综合久久中文字幕一本 | 久久久福利| 亚洲精品一区二区在线播放 | 精品牛牛影视久久精品 | 奇米成人网| 91私拍| 久久免费视频在线观看 | 欧美日本三级 | 日本狠狠操 | 日本一级在线观看视频播放 |