Thanks for your clarification.
I am testing this scenario.. I am recreating as a MV which is using DBMS_JOBS to refresh in another schema, Idealy i am trying migrate from DBMS_JOBS to DBMS_SCHEDULER..
Below is MV query (model)..
- Code: Select all
CREATE MATERIALIZED VIEW "SYS"."CHECKLIST" ("ID", "I_DATE") ORGANIZATION HEAP PCTFREE 10 PCTUSED 0 INITRANS 2 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SYSAUX" BUILD IMMEDIATE USING INDEX REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT sysdate+1 USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE AS
SELECT DISTINCT n2.name AS ID,SYSDATE AS I_DATE
FROM
(SELECT id,name,pencilviewpkg.getcontextname (id, 5976913, 200, NULL) AS nname
FROM admin_all WHERE subtypeid =
(SELECT id FROM admin_all WHERE nodetype = 't' AND name = 'Vendor'
)
) vend
INNER JOIN
(SELECT * FROM time_out WHERE present <> 12
) l1
ON l1.parentid = vend.id
INNER JOIN
(SELECT * FROM time_out WHERE present <> 12
) l2
ON l1.childid = l2.parentid
INNER JOIN
(SELECT * FROM time_out WHERE present <> 12 AND present <> 1382529
) l3
ON l2.childid = l3.parentid
INNER JOIN admin_all n
ON n.id = l2.childid
INNER JOIN admin_all n2
ON n2.id = l3.childid
WHERE pencilviewpkg.getcontextname (l1.childid, 5976913, 200, NULL) = 'Products';
I created this MV in SYS schema so that i can try dbms_scheduler to refresh the job.
I tried creating the job as below.. It failed. Looks like a syntax error but couldn't figure out.

- Code: Select all
SQL> BEGIN
2 DBMS_SCHEDULER.create_job (
3 job_name => 'CHECKLIST',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN dbms_refresh.refresh('"SYS"."CHECKLIST"'); END;',
start_date => SYSTIMESTAMP,
4 5 6 7 repeat_interval => 'freq=hourly; byhour=0; byminute=30; bysecond=0;'
8 end_date => NULL,
9 enabled => TRUE,
comments => 'CHECKLIST MV REFRESH JOB');
10 11 End;
12 /
job_action => 'BEGIN dbms_refresh.refresh('"SYS"."CHECKLIST"'); END;',
*
ERROR at line 5:
ORA-06550: line 5, column 45:
PLS-00103: Encountered the symbol "SYS" when expecting one of the following:
) , * & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
Also, When i checked the DBA JOBS..A new job was listed. I think it got created when i created the MV..Please clarify.
- Code: Select all
JOB LOG_USER LAST NEXT FAIL WHAT
----- --------------- --------------- --------------- ----- --------------------------------------------------
51 CHECKVW 01/05/12 00:18 01/05/12 12:18 0 dbms_refresh.refresh('"CHECKVW"."CHECKLIST"');
71 SYS 01/05/12 06:31 02/05/12 06:31 0 dbms_refresh.refresh('"SYS"."CHECKLIST"');
OWNER MVIEW_NAME LAST_REFRESH
------------------------------ ------------------------------ --------------------
CHECKVW CHECKLIST 01/05/12 00:18
SYS CHECKLIST 01/05/12 06:31
In this case, How will i move this job to scheduler. Do i need to specify anything in the MV create script?
Ideally, I want to refresh the MV(CHECKVW) using scheduler to have better control and not with DBMS_JOBS.. Please advise and let me know if my approach is incorrect.
Thanks in advance.