日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle存储过程行转列,oracle 存储过程-动态行转列,解决。

發布時間:2023/12/10 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle存储过程行转列,oracle 存储过程-动态行转列,解决。 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

create or replace package body pro_test isprocedure Alarm_ContentsByTime(

p_StartTime varchar2,----開始時間

p_EndTime varchar2,----結束時間

io_cursorinOUT out_cursor

)iscursor cursor_1 IS--獲取 列用于循環。select DISTINCT t.ps_productorcode code, t.PS_PRODUCTORNAME name,1type FROM PSINFO_PRODUCTYIELD_SB t

union allselect DISTINCT f.ps_rawcode code,f.ps_rawname name,2 type fromPSINFO_RAWMATERIALS_SB f

ORDER BY type,code;

V_SQL VARCHAR2(6000);

begin

V_SQL := ‘select‘‘市本級‘‘as c0003_stname, 1 as c0003_stcode‘;

FOR V_XCLCK IN cursor_1

LOOP

V_SQL := V_SQL || ‘,‘ || ‘min(case when t1.ps_name=‘‘‘ || V_XCLCK.name ||

‘‘‘then t1.ps_name end) as‘ || V_XCLCK.name||‘mc‘|| ‘,‘ || ‘min(case when t1.ps_name=‘‘‘ || V_XCLCK.name ||

‘‘‘then t1.cl end) as‘ || V_XCLCK.name||‘cl‘|| ‘,‘ || ‘min(case when t1.ps_name=‘‘‘ || V_XCLCK.name ||

‘‘‘then t1.ps_unit end) as‘ || V_XCLCK.name||‘dw‘;END LOOP;

V_SQL := V_SQL || ‘from t0003_station t

inner join (selectc.c0003_stcode,

c.c0003_stname,

a.ps_productorname ps_name,

a.ps_unit,

sum(nvl(a.ps_productoryield,0)) clfromt0003_station c,PSINFO_PRODUCTYIELD_SB awhere a.c0003_stcode=c.c0003_stcode

and a.ps_month>=to_date(‘‘‘||p_StartTime||‘‘‘,‘‘yyyy-mm-dd hh24:mi:ss‘‘)

and a.ps_month<=to_date(‘‘‘||p_EndTime||‘‘‘,‘‘yyyy-mm-dd hh24:mi:ss‘‘)

group by c.c0003_stcode,c.c0003_stname,a.ps_productorname,a.ps_unit

union allselectc.c0003_stcode,

c.c0003_stname,

b.ps_rawname ps_name,

b.ps_unit,

sum(nvl(b.ps_productoryield,0)) clfromt0003_station c,PSINFO_RAWMATERIALS_SB bwhere b.c0003_stcode=c.c0003_stcode

and b.ps_month>=to_date(‘‘‘||p_StartTime||‘‘‘,‘‘yyyy-mm-dd hh24:mi:ss‘‘)

and b.ps_month<=to_date(‘‘‘||p_EndTime||‘‘‘,‘‘yyyy-mm-dd hh24:mi:ss‘‘)

group by c.c0003_stcode,c.c0003_stname,b.ps_rawname,b.ps_unit

) t1 on t.c0003_stcode=t1.c0003_stcode

left join t0070_enterprise t70 on

t.c0003_stcode=t70.c0003_stcode

and t70.c0003_year=t1.c0003_stcode

and t70.c0070_stcode_ctrl=‘‘320100‘‘group by t.c0003_stname,t.c0003_stcode‘;

DBMS_OUTPUT.PUT_LINE(V_SQL);--V_SQL := ‘CREATE OR REPLACE VIEW RESULT AS‘||V_SQL;

open io_cursorforV_SQL;

end Alarm_ContentsByTime;

end pro_test;

總結

以上是生活随笔為你收集整理的oracle存储过程行转列,oracle 存储过程-动态行转列,解决。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。