oracle 使用pivot 函数进行批量数据的动态行转列
时间:2021-07-01 10:21:17
帮助过:6人阅读
P_FXJG
AS
v_LM VARCHAR2(
2000);
vs_sql varchar2(
6000);
vs_sql1 varchar2(
6000);
BEGIN
vs_sql1 := ‘INSERT INTO LS_TEMP select dbms_lob.substr(wm_concat(distinct(sf))) from B_CLB a ‘;
execute immediate vs_sql1;
SELECT SFBM
INTO V_LM
FROM LS_TEMP;
vs_sql := ‘create or replace view V_FXJG as select * from (select a.YH, a.MC, a.LX "BZ", a.SF, a.JG from B_CLB a ) pivot(sum(JG) for SF in(‘ ||
V_LM || ‘))‘;
execute immediate vs_sql;
END;
oracle 使用pivot 函数进行批量数据的动态行转列
标签:distinct arc RoCE rom varchar2 begin for exe cut