黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

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

Oracle動態(tài)SQL拼接

更新時間:2021-11-08 12:54:06 來源:動力節(jié)點 瀏覽1349次

1. 直接用單引號,單引號的使用是就近配對,即就近原則。從第二個單引號開始被視為轉(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)義單引號

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占位符語法處理

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)知識,可以來關(guān)注一下動力節(jié)點的Oracle教程,里面的內(nèi)容詳細(xì),通俗易懂,適合小白學(xué)習(xí)。

提交申請后,顧問老師會電話與您溝通安排學(xué)習(xí)

免費課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 亚洲国产三级 | 国产精品久久久久网站 | 男人天堂色 | 成人在线黄色 | 美女一级大黄录像一片 | 夜夜操女人 | 一级黄色大片免费 | 欧美激情视频免费 | 日韩成人高清 | 久久99精品视免费看 | 曰批全过程免费视频网址 | 男人下身进女人阳道视频 | 成人毛片免费网站 | 人人做人人看 | 香蕉视频网址 | 最近中文字幕在线 | 男女视频在线观看免费高清观看 | 五月婷在线 | 欧美zozozo人禽交免费大片 | 欧美国产精品 | 国产一区二区三区高清视频 | 成人免费看片视频色多多 | 日韩精品一区二区三区在线观看l | 欧美成人久久一级c片免费 欧美成人看片 | 免费人成网站在线高清 | 高清欧美一区二区三区 | www.色偷偷.com| 青青草国产 | 国产三区视频 | 狠狠色狠狠色综合人人 | 在线观看毛片视频 | 最近的2019中文字幕国语hd | 免费无遮h在线网站大全 | 福利视频欧美一区二区三区 | 亚洲天堂视频在线免费观看 | 在线观看国产高清免费不卡黄 | 波多野结衣视频一区二区 | 欧美成人免费做真爱大片 | 国产黄色大片又色又爽 | 最刺激黄a大片免费观看 | 成年性午夜免费视频网站不卡 |