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

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

Oracle動態SQL拼接

更新時間:2021-11-08 12:54:06 來源:動力節點 瀏覽1352次

1. 直接用單引號,單引號的使用是就近配對,即就近原則。從第二個單引號開始被視為轉義符

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)轉義單引號

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;

如果大家想了解更多相關知識,可以來關注一下動力節點的Oracle教程,里面的內容詳細,通俗易懂,適合小白學習。

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

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 亚洲黄色片视频 | 欧美成人免费全网站大片 | www天天操| 免费观看黄色录像 | 四虎免费在线观看视频 | 嘿咻成人免费视频欧美激情 | 一级毛片一级毛片a毛片欧美 | www.午夜色 | 国产精品久久久久久久久免费 | 午夜免费看| 国产福利视精品永久免费 | 久九精品| 偷亚洲偷国产欧美高清 | 亚洲高清资源在线观看 | 亚洲精品久久久久久动漫剧情 | 国产精品免费观看视频 | 久久精品视频日本 | 成人国内精品久久久久影院 | 2019亚洲日韩新视频 | 天天看天天射 | 久久久久久久久久久观看 | 60欧美老妇做爰视频 | 色丁香在线观看 | 欧美成人一级毛片 | 女人18毛片a级毛片免费 | 久久中文字幕一区二区 | 国产综合欧美日韩视频一区 | a一级日本特黄aaa大片 | 伊人成人久久 | 最新亚洲精品国自产在线 | 午夜精品久久久久久99热 | 中国美女一级a毛片录像在线 | 动漫精品一区二区3d | 高清不卡一区 | 成年美女| 玖玖国产在线观看 | 在线观看国产91 | 美女a毛片 | 久久久窝窝午夜精品 | 精品久久久久久午夜 | 狠狠色综合久久婷婷色天使 |