I have the following Oracle DDL code within a stored procedure in Oracle 13.0 through TOAD:
--BUILD AND POPULATE MATERIALIZED VIEWS
BEGIN
EXECUTE IMMEDIATE 'DROP MATERIALIZED VIEW WORK.Work1_MV';
EXCEPTION
WHEN OTHERS
THEN NULL;
END;
--Create Materialized View (PLS-00103 Error)*
CREATE MATERIALIZED VIEW WORK.Work1_MV
NOLOGGING
BUILD DEFERRED
AS
SELECT *
FROM WORK.WorkA_V
;
BEGIN
DBMS_MVIEW.REFRESH ('WORK.Work1_MV', 'C', ATOMIC_REFRESH => FALSE);
END;
COMMIT;
--Create Index on Materialized View (PLS-00103 Error)*
CREATE BITMAP INDEX WORK.Work1_MV_MAP1 ON WORK.Work1_MV
(ELEMENT_NAME)
NOLOGGING
COMPUTE STATISTICS;
--Create 2nd Index on Materialized View (PLS-00103 Error)*
CREATE BITMAP INDEX WORK.Work1_MV_MAP2 ON WORK.Work1 MV
(MAP_ID)
NOLOGGING
COMPUTE STATISTICS;
When the above are ran separately, they seem to work. However, while embedded in a stored procedure; they fail to compile with the PLS-00103 errors pertaining to the sections I have commented in the above code.
The complete error message is below:
"[ERROR] PLS-00103 (329: 5): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: (begin case declare end exception exit for goto if loop mod null pragma raise return select update while with)"
I would greatly appreciate if anyone can share solutions to compile these statements correctly.
Thank you.
execute immediate
for each statement). Are you sure that you want bitmap indexes? And are you sure that you want to drop and re-create the materialized view every time rather than just refreshing it? – Justin Cave