大战熟女丰满人妻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 | 奇米影视666 | 中文字幕国产亚洲 | 米奇精品一区二区三区 | 伊人高清视频 | 国产免费私人影院永久免费 | 成人精品亚洲人成在线 | 中文字幕亚洲精品久久 | 91成人免费福利网站在线 | 成人免费视频在线看 | 97视频在线观看免费 | 免费爽视频| 中文字幕色婷婷在线视频 | 欧美娇小www | 2020亚洲欧美日韩在线观看 | 一级视频片 | 欧美高清免费精品国产自 | 国产精品久久一区一区 | 久久国产免费福利永久 | 综合欧美一区二区三区 | 日本高清免费毛片久久看 | 免费观看国产网址你懂的 | 五月免费视频 | 999在线观看视频 | 成人国产三级精品 | 亚洲国产欧洲精品路线久久 | 亚洲人成毛片线播放 | 裸身裸乳免费视频网站 | 99爱视频在线观看免费播放 | 高清国产一级毛片国语 | 国产中文 | 欧美日本一道免费一区三区 | 99精品国产兔费观看久久99 | 最新中文字幕一区 | 亚洲aⅴ久久久噜噜噜噜 | 99久久这里只精品国产免费 | 欧美成人午夜视频 | 黄色操视频 |