declare
t_sql varchar2(1000);
t_strcd varchar2(10);
t_nowfirst varchar2(30);
incomcd varchar2(30);
t_jxflag varchar2(30);
indate varchar2(30);
t_table varchar2(30);
begin
t_sql := t_sql || ' insert into ' || t_table;
t_sql := t_sql || '(gmspsid0p_comcd,gmspsid0p_strcd,gmspsid0p_div,gmspsid0p_dep,';
t_sql := t_sql || 'gmspsid0p_dpt,gmspsid0p_class,gmspsid0p_area,gmspsid0p_intcd,';
t_sql := t_sql || 'gmspsid0p_saldate,gmspsid0p_mdprice,gmspsid0p_mdnetprice,gmspsid0p_grsprice,';
t_sql := t_sql || 'gmspsid0p_grscost,gmspsid0p_netprice,gmspsid0p_netcost,gmspsid0p_fresh***,';
t_sql := t_sql || 'gmspsid0p_supcd,gmspsid0p_conno)';
t_sql := t_sql || ' select gmsmmitm_comcd,:t_strcd,gmsmmitm_divcd,gmsmmitm_depcd,';
t_sql := t_sql || 'gmsmmitm_dptcd,gmsmmitm_clscd,gmsmmitm_areacd,gmsmmitm_intcd,';
t_sql := t_sql || 'to_date(:t_nowfirst,:t_format2),gmsmmitm_grscost,gmsmmitm_netcost,gmsmmitm_grsprice,';
t_sql := t_sql || 'gmsmmitm_grscost,gmsmmitm_netprice,gmsmmitm_netcost,gmsmmitm_fresh***,';
t_sql := t_sql || 'gmsmmitm_vendor,gmsmmitm_contract';
t_sql := t_sql || ' from gmsmm_itemb ';
t_sql := t_sql || ' where gmsmmitm_comcd =:t_comcd1 ';
t_sql := t_sql || ' and gmsmmitm_manager =:t_jxflag1 ';
t_sql := t_sql || ' andto_char(gmsmmitm_createdate,''yyyymmdd'') = :t_date1 ';
t_sql := t_sql || ' and exists (select 1 fromgmspsi_item ';
t_sql := t_sql || ' where gmspsiitm_comcd =gmsmmitm_comcd ';
t_sql := t_sql || ' and gmspsiitm_strcd =:t_strcd3 ';
t_sql := t_sql || ' and gmspsiitm_intcd =gmsmmitm_intcd)';
execute immediate t_sql
--引用動態,並且還可以對資料進行再次判斷後執行
using t_strcd, t_nowfirst, 'yyyymmdd', incomcd, t_jxflag,rtrim(indate), case when t_loop = t_from then t_strcd else 0 end
end;
/
execute immediate的使用技巧
使用技巧 1.execute immediate將不會提交乙個dml事務執行,應該顯式提交 假如通過execute immediate處理dml命令,那麼在完成以前需要顯式提交或者作為execute immediate自己的一部分.假如通過execute immediate處理ddl命令,它提交所有...
EXECUTE IMMEDIATE用法小解
execute immediate 代替了以前oracle8i中dbms sql package包.它解析並馬上執行動態的sql語句或非執行時建立的pl sql塊.動態建立和執行sql語句效能超前,execute immediate的目標在於減小企業費用並獲得較高的效能,較之以前它相當容易編碼.儘管...
EXECUTE IMMEDIATE用法小解
execute immediate 代替了以前oracle8i中dbms sql package包.它解析並馬上執行動態的sql語句或非執行時建立的pl sql塊.動態建立和執行sql語句效能超前,execute immediate的目標在於減小企業費用並獲得較高的效能,較之以前它相當容易編碼.儘管...