ストアドプロシージャを呼び出すたびにピボット結果を挿入するテーブルがある場合は、次を使用できます。
CREATE OR REPLACE PROCEDURE dynamic_pivot
AS
v_sql LONG := NULL;
v_statement LONG := NULL;
BEGIN
SELECT DISTINCT LISTAGG(''''
|| myLetter
|| ''' AS '
|| myLetter,',') WITHIN GROUP (
ORDER BY myLetter) AS temp_in_statement
INTO v_statement
FROM
(SELECT DISTINCT myLetter FROM test_data
);
v_sql := 'insert into pivot_table
select * from (SELECT myNumber, myLetter, myValue FROM test_data
)
PIVOT
(
SUM(myValue) AS val FOR myLetter IN (' || v_statement || ')
)';
EXECUTE immediate v_sql;
END;