国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

帶參數動態執行sql語句:Execute Immediate

2024-07-21 02:34:07
字體:
來源:轉載
供稿:網友

  根據客戶需要,我們增加了一個統計表,用來匯總統計數據,統計數據的產生,需要根據一個基本表,動態執行sql語句.在存儲過程中,動態生成sql語句然后執行,需要用到Execute Immediate命令.我想寫一個通用的統計用存儲過程,似乎不大好辦,if語句的應用在所難免了.呵呵.
  
  特此存檔.
  
  create or replace PRocedure P_INSERT_XT_TJ_MX(sDate in varchar2) is
  --author:李春雷
  --create time:2005.8.4
  --purpose:更新xt_tj_mx表
  sXh xt_tj.xh%type;             --主表序號
  sDwmc xt_tj.dwmc%type;
  sDw xt_tj.dw%type;
  sDwzd xt_tj.dwzd%type;
  sTable xt_tj.hzbmc%type;
  sSjzd xt_tj.sjzd%type;
  sSqlStr varchar2(300);
  iCount int;
  cursor curSort is
  select xh,dwmc,hzbmc,sjzd,dwzd,dw from xt_tj ;
  begin
  open curSort;
  loop
  fetch curSort into sXh,sDwmc,sTable,sSjzd,sDwzd,sDw;
  exit when curSort%notfound;
  sSqlStr := 'select count(*) from ' sTable ' where to_char('sSjzd',''''YYYYMM'')=:sDate and 'sDwzd
  ' in (select dwxh from xt_dw connect by prior dwxh = dwfxh start with dwxh =:sDw)';
  Execute Immediate sSqlStr into iCount using sDate,sDw;
  delete from xt_tj_mx where fxh=sXh and sjz=sDate;
  insert into xt_tj_mx(xh,fxh,hzsm,sjz)values(SEQ_XT_TJ_MX.NEXTVAL,sXh,iCount,sDate);
  commit;
  end loop;
  end P_INSERT_XT_TJ_MX;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨竹工卡县| 鸡东县| 汝州市| 阿城市| 嘉荫县| 景谷| 凭祥市| 乌什县| 临高县| 沽源县| 台山市| 巴彦县| 渑池县| 达尔| 常熟市| 金坛市| 集贤县| 瑞金市| 阿城市| 永康市| 新泰市| 大埔县| 海伦市| 邮箱| 疏勒县| 哈尔滨市| 武安市| 普安县| 祥云县| 寿宁县| 深水埗区| 河源市| 泽普县| 苏尼特左旗| 叙永县| 都江堰市| 襄垣县| 基隆市| 平南县| 冕宁县| 鲁山县|