Create an Oracle job with a global temporary table during Oracle statistics

Source: Internet
Author: User

1. Create an Oracle global temporary table. The Code is as follows:
SQL code

  1. DECLARECntInt;
  2. Begin
  3. -- If the temporary table exists, delete it.
  4. SELECT Count(1)IntoCntFromUser_tablesWhereTable_name ='Templogsmshall _ session';
  5. If cnt> 0THEN
  6. BEGIN
  7. ExecuteImmediate'Drop TABLE TEMPLOGSMSHALL_SESSION';
  8. END;
  9. EndIf;
  10. End;
  11. /
  12. -- Create a temporary table
  13. CREATE GLOBAL TEMPORARY TABLETempLogSmsHall_Session (
  14. SESSIONID VARCHAR2 (28)NOT NULL,
  15. USERTELNO VARCHAR2 (16)NOT NULL,
  16. USERCITYNAME VARCHAR2 (8)NOT NULL,
  17. USERBRANDNAME VARCHAR2 (16)NOT NULL,
  18. NLIBIZNAME VARCHAR2 (32)NOT NULL,
  19. BIZNAME VARCHAR2 (128)NOT NULL,
  20. OPERATIONNAME VARCHAR2 (16)NOT NULL,
  21. SCENEHANDLETYPE VARCHAR2 (32)NOT NULL,
  22. SCENEHANDLEID VARCHAR2 (6)NOT NULL,
  23. SESSIONBEGINTIMETIMESTAMPNOT NULL,
  24. SESSIONENDTIMETIMESTAMPNOT NULL,
  25. ISTIMEOUTCHAR(1)DEFAULT '1' NOT NULL,
  26. ALLCOSTSECONDSINTEGERDEFAULT(0)NOT NULL,
  27. REVSMSNUMINTEGERDEFAULT(0)NOT NULL,
  28. SENDSMSNUMINTEGERDEFAULT(0)NOT NULL
  29. )
  30. ON COMMITPRESERVEROWS;
The temporary table created above is independent of each stored procedure or PL/SQL block that calls it and does not affect each other. That is to say, two PL/SQL statements can be called at the same time, and the result pages will not affect each other.

2. Create an Oracle job with the following code:
SQL code
  1. DECLAREJob NUMBER;
  2. Begin
  3. Dbms_job.submit (job => job,
  4. What =>'Ecss _ JOB. SMSS10_Job_DailyStatus ('''');',
  5. Next_date => trunc (sysdate) + (1 + 1/24 ),
  6. Interval =>'Sysdate + 1');
  7. Commit;
  8. End;
Where: job is the number automatically generated by the system, ECSS_JOB.SMSS10_Job_DailyStatus is a process (there is also a string parameter), next_date sets the next execution time, here is tomorrow morning, interval sets the interval, how long is the execution performed every day. The trunc function is used to remove the time in the date, that is, to get the of a day. The time is in the unit of day. Therefore, to get a score of, you need to score:

1/24 hour;
1/1440 points;
1/3600 seconds;

In addition, note that the SQL statement should not be executed multiple times, and several jobs will be submitted after the SQL statement is executed several times.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.