While running this prepared statement
DECLARE
BEGIN
-- Get the list of dependent tables and store it in a variable.
FOR cons IN (SELECT A.TABLE_NAME
FROM ALL_CONSTRAINTS A, ALL_CONSTRAINTS B
WHERE A.CONSTRAINT_TYPE = 'xxx'
AND A.R_CONSTRAINT_NAME = B.CONSTRAINT_NAME
AND A.R_OWNER = B.OWNER
AND B.TABLE_NAME = 'MY_TABLE'
AND B.OWNER = 'DBA')
LOOP
SET @querytext = CONCAT('SELECT * FROM ',cons.TABLE_NAME);
PREPARE stamquery FROM @querytext;
EXECUTE stamquery;
DEALLOCATE PREPARE stamquery;
END LOOP;
END;
I am getting the error stating:
Encountered the symbol "STAMQUERY" when expecting one of the following:
:= . ( @ % ;
I am new with procedures but looks like this is the way to do it based on my research on the internet.
Please let me know what am I doing wrong..
SET @querytext = ...is invalid PL/SQL. Where in the manual did you find tha?