¤ë‌¼´ SQLê³¼ PL/SQL‌„ ë‹¤ë£¨ë” ê¸°ˆ  - 15‍¥.¤ë‌¼´ ‍ê³¼ ¤¼€¤„ë¬

  • View
    127

  • Download
    27

Embed Size (px)

Text of ¤ë‌¼´ SQLê³¼ PL/SQL‌„...

  1. 1. The Technique of Java Programming
  2. 2. !!!!
  3. 3. SQL PL/SQL : , ! : - SQL&PL/SQL - Head First
  4. 4. . PL/SQL 15
  5. 5. 01 DBMS_JOB DBMS_SCHEDULER DBMS_SCHEDULER 02 03
  6. 6. 01 DBMS_JOB DBMS_JOB () USER_JOBS
  7. 7. 01 DBMS_JOB.SUMMIT DBMS_JOB DBMS_JOB.SUBMIT ( job OUT BINARY_INTEGER, what IN VARCHAR2, next_date IN DATE DEFAULT SYSDATE, interval IN VARCHAR2 DEFAULT 'NULL', no_parse IN BOOLEAN DEFAULT FALSE, instance IN BINARY_INTEGER DEFAULT ANY_INSTANCE, force IN BOOLEAN DEFAULT FALSE); job : , . what : , SQL PL/SQL . next_date : (), SYSDATE. interval : , .
  8. 8. 01 DBMS_JOB.SUMMIT DBMS_JOB interval 1 : SYSDATE + 7 1 : SYSDATE + 1 1 1 : SYSDATE + 1/24 1 1 : SYSDATE + 1/60/24 10 1 : SYSDATE + 10 / 60 / 60 / 24 ( COMMIT) -- 1 1 ch15_job_test_proc DBMS_JOB.SUBMIT ( job => v_job_no, what => 'ch15_job_test_proc;', next_date => SYSDATE, interval => 'SYSDATE + 1/60/24' ); -- 1 1
  9. 9. 01 DBMS_JOB.BROKEN DBMS_JOB DBMS_JOB.BROKEN ( Job IN BINARY_INTEGER, broken IN BOOLEAN, next_date IN DATE DEFAULT SYSDATE); job : broken : TRUE, FALSE next_date : (), SYSDATE. COMMIT
  10. 10. 01 DBMS_JOB.BROKEN DBMS_JOB BEGIN -- DBMS_JOB.BROKEN (30, TRUE); COMMIT; END;
  11. 11. 01 DBMS_JOB.CHANGE DBMS_JOB DBMS_JOB.CHANGE ( job IN BINARY_INTEGER, what IN VARCHAR2, next_date IN DATE, interval IN VARCHAR2, instance IN BINARY_INTEGER DEFAULT NULL, force IN BOOLEAN DEFAULT FALSE); job : what : , SQL PL/SQL. next_date : (). interval : .
  12. 12. 01 DBMS_JOB.RUN DBMS_JOB DBMS_JOB.RUN ( job IN BINARY_INTEGER, force IN BOOLEAN DEFAULT FALSE);
  13. 13. 01 DBMS_JOB.REMOVE DBMS_JOB DBMS_JOB.REMOVE ( job IN BINARY_INTEGER );
  14. 14. 01 DBMS_JOB DBMS_JOB SQL PL/SQL
  15. 15. 02 DBMS_SCHEDULER DBMS_SCHEDULER DBMS_JOB . 10g DBMS_SCHEDULER , , , , SQL, , (OS )
  16. 16. 02 DBMS_SCHEDULER , OS , , 3 : , : PLSQL_BLOCK( ), STORED_PROCEDURE(), EXTERNAL( ) :
  17. 17. 02 DBMS_SCHEDULER DBMS_JOB next_date interval : :
  18. 18. 02 (Job) DBMS_SCHEDULER
  19. 19. 02 DBMS_SCHEDULER.CREATE_PROGRAM DBMS_SCHEDULER DBMS_SCHEDULER.CREATE_PROGRAM ( program_name IN VARCHAR2, program_type IN VARCHAR2, program_action IN VARCHAR2, number_of_arguments IN PLS_INTEGER DEFAULT 0, enabled IN BOOLEAN DEFAULT FALSE, comments IN VARCHAR2 DEFAULT NULL);
  20. 20. 02 DBMS_SCHEDULER.CREATE_PROGRAM DBMS_SCHEDULER program_name : , . program_type : 'PLSQL_BLOCK' 'PROCEDURE' 'EXECUTABLE' program_action : , , number_of_arguments : program_type 'PROCEDURE' 'EXECUTABLE' , 0. enabled : . FALSE comments :
  21. 21. 02 DBMS_SCHEDULER.CREATE_PROGRAM DBMS_SCHEDULER BEGIN DBMS_SCHEDULER.CREATE_PROGRAM ( program_name => 'my_program1', program_type => 'STORED_PROCEDURE', program_action => 'ch15_job_test_proc ', comments => ' '); END;
  22. 22. 02 DBMS_SCHEDULER.CREATE_SCHEDULE DBMS_SCHEDULER DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name IN VARCHAR2, start_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL, repeat_interval IN VARCHAR2, end_date IN TIMESTAMP WITH TIMEZONE DEFAULT NULL, comments IN VARCHAR2 DEFAULT NULL);
  23. 23. 02 DBMS_SCHEDULER.CREATE_SCHEDULE DBMS_SCHEDULER schedule_name : , start_date : repeat_interval : . ( FREQ, INTERVAL, BYMONTH, BYDAY, ) end_date : comments :
  24. 24. 02 DBMS_SCHEDULER.CREATE_SCHEDULE DBMS_SCHEDULER repeat_interval FREQ=DAILY; BYDAY=MON; ( , ) FREQ=WEEKLY; BYDAY=MON; ( , ) FREQ=YEARLY; BYDAY=MON; ( , ) FREQ=WEEKLY; INTERVAL=2; BYDAY=MON; FREQ=MONTHLY; BYMONTHDAY= -1; 5 10 FREQ=YEARLY; BYMONTH=MAY; BYMONTHDAY=10; FREQ=YEARLY; BYDATE=0510; 25 FREQ=MONTHLY; BYMONTHDAY=25; FREQ=MONTHLY; BYDAY=2WED; 6, 6 FREQ=DAILY; BYHOUR=06,18; 1 FREQ=HOURLY; INTERVAL=1; ( 1 1 ) 10 1 FREQ=HOURLY; INTERVAL=1; BYMINUTE=10; 1 FREQ=MINUTELY; INTERVAL=1;
  25. 25. 02 DBMS_SCHEDULER.CREATE_SCHEDULE DBMS_SCHEDULER BEGIN DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'my_schedule1', start_date => NULL, repeat_interval => 'FREQ=MINUTELY; INTERVAL=1', -- 1 1 end_date => NULL, comments => '1 '); END;
  26. 26. 02 DBMS_SCHEDULER.CREATE_JOB DBMS_SCHEDULER , 4 () ,
  27. 27. 02 DBMS_SCHEDULER.CREATE_JOB DBMS_SCHEDULER DBMS_SCHEDULER.CREATE_JOB ( job_name IN VARCHAR2, job_type IN VARCHAR2, job_action IN VARCHAR2, number_of_arguments IN PLS_INTEGER DEFAULT 0, start_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, repeat_interval IN VARCHAR2 DEFAULT NULL, end_date IN TIMESTAMP WITH TIME ZONE DEFAULT NULL, job_class IN VARCHAR2 DEFAULT 'DEFAULT_JOB_CLASS', enabled IN BOOLEAN DEFAULT FALSE, auto_drop IN BOOLEAN DEFAULT TRUE, comments IN VARCHAR2 DEFAULT NULL, );
  28. 28. 02 DBMS_SCHEDULER DBMS_SCHEDULER.ENABLE ( name IN VARCHAR2, commit_semantics IN VARCHAR2 DEFAULT 'STOP_ON_FIRST_ERROR'); DBMS_SCHEDULER.DISABLE ( name IN VARCHAR2, force IN BOOLEAN DEFAULT FALSE, commit_semantics IN VARCHAR2 DEFAULT 'STOP_ON_FIRST_ERROR');
  29. 29. 02 DBMS_SCHEDULER DBMS_SCHEDULER.SET_ATTRIBUTE DBMS_SCHEDULER.SET_ATTRIBUTE_NULL DBMS_SCHEDULER.DROP_PROGRAM DBMS_SCHEDULER.DROP_SCHEDULE DBMS_SCHEDULER.DROP_JOB
  30. 30. 03 DBMS_SCHEDULER CREATE_JOB BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'my_job1', job_type => 'STORED_PROCEDURE', job_action => 'ch15_job_test_proc ', repeat_interval => 'FREQ=MINUTELY; INTERVAL=1', -- 1 1 comments => '1 ' ); DBMS_SCHEDULER.ENABLE ('my_job1'); -- END;
  31. 31. 03 , DBMS_SCHEDULER BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'my_job2', program_name => 'MY_PROGRAM1', schedule_name => 'MY_SCHEDULE1', comments => '2 ' ); DBMS_SCHEDULER.ENABLE ('my_job2'); -- END;
  32. 32. 03 DBMS_SCHEDULER DB , OS OracleJobScheduler
  33. 33. 03 DBMS_SCHEDULER BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'MY_EX_JOB1', -- job_type => 'EXECUTABLE', -- job_action => 'c:windowssystem32cmd.exe', -- CMD.EXE number_of_arguments => 2, -- 2 repeat_interval => 'FREQ=MINUTELY; INTERVAL=1', -- 1 1 comments => ' ' ); -- DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('MY_EX_JOB1',1,'/c'); -- 1 -- 2 ( ) DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('MY_EX_JOB1',2,'c:scheduler_test.bat'); DBMS_SCHEDULER.ENABLE ('MY_EX_JOB1'); -- END;
  34. 34. 03 DBMS_SCHEDULER () DBMS_SCHEDULER.CREATE_CHAIN DBMS_SCHEDULER.DEFINE_CHAIN_STEP DBMS_SCHEDULER.DEFINE_CHAIN_RULE