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

專注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é)點 瀏覽1387次

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)容詳細,通俗易懂,適合小白學習。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 99久久99久久精品免费看蜜桃 | 亚洲精品久久久中文字幕 | 国产二级毛片 | 91成人免费观看网站 | 青青青青久久精品国产h | 国产精品欧美亚洲 | 欧美性精品不卡在线观看 | 精品久久伦理中文字幕 | 深夜精品寂寞在线观看黄网站 | 久久久久一区二区三区 | 日本一级毛片大片免费 | 免费精品久久久久久中文字幕 | 99视频精品免视3 | 91激情视频| 老司机午夜在线视频免费观 | 2022国产91精品久久久久久 | 日日拍夜夜操 | 婷婷亚洲视频 | 国产精品亚洲精品观看不卡 | 欧美另类黑人巨大videos | 伊人久久成人成综合网222 | 欧美久久影院 | 2020国产精品视频 | 国产亚洲欧美在在线人成 | 国产网红福利 | 日韩影片在线观看 | 米奇精品一区二区三区 | 国产精品久久久久无毒 | 国产精品天天操 | 高清在线一区 | 狠狠色噜狠狠狠狠 | 久久视频精品a线视频在线观看 | 久久手机视频 | 伊人久久久综在合线久久在播 | 精品无码久久久久久久动漫 | 日韩 在线视频精品 | 亚洲色四在线视频观看 | 在线观看国产精美视频 | 亚洲欧美中文字幕在线网站 | 欧美一级毛片免费播放器 | 日本成人不卡视频 |