table1 ==> rowname ==> a
b
现在写了个函数sell输出
'a,b 'table2 ==> a
b
c
列
---------------------------------------------------------------------------------------------------------
求 select 'a,b ' from table2
转换成 select a,b from table2
b
现在写了个函数sell输出
'a,b 'table2 ==> a
b
c
列
---------------------------------------------------------------------------------------------------------
求 select 'a,b ' from table2
转换成 select a,b from table2
SELECT WMSYS.WM_CONCAT(rowname) rowname INTO v_rowname FROM TABLE1;
v_sql:='select '||v_rowname||' from table2';
execute immediate V_SQL;
PROCEDURE PRO_COALSELLTAX AS
v_Row varchar(50);
v_Rows varchar(500);
v_num number(4) := 0;
cursor userRows is
select columnName from taxationmiddle ttm left join taxtype tt on tt.id=ttm.taxtypeid where tt.TAXSOURCE=1 ;
BEGIN
for v_Row in userRows loop
--dbms_output.put_line(v_Row.columnName);
if(v_num =0)
then
v_Rows := 'select ' || v_Row.columnName;
else
v_Rows := v_Rows ||','|| v_Row.columnName;
end if;
v_num := v_num +1;
end loop;
v_Rows := v_Rows || ' from COALSELLTAX';
dbms_output.put_line(v_Rows);
execute immediate v_Rows;
END PRO_COALSELLTAX;