For my question I have set up a simple example to illustrate my problem.
Let's say you have a dynamic query that generates several select statements with a UNION ALL between them. Is there a way to prevent the 'UNION ALL' at the end of the last record from appearing?
My example:
CREATE OR REPLACE PROCEDURE PROC_TEST AS
BEGIN
DECLARE
DDL_STRING CLOB;
BEGIN
FOR x IN (SELECT TABLE_NAME FROM HLP_TABLES WHERE ENABLED = 1)
LOOP
DDL_STRING := 'SELECT ID FROM ' || x.TABLE_NAME || ' UNION ALL ';
DBMS_OUTPUT.PUT_LINE(DDL_STRING);
END LOOP;
END;
END PROC_TEST;