Thứ Hai, 19 tháng 4, 2021

[oracle] SQL tạo procedure và job

I. References

  1. https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6009.htm
  2. https://docs.oracle.com/html/E25494_01/scheduse002.htm#i1009668

II.Tutorial
1. Tạo procedure
create or replace PROCEDURE synAirtimeReport as
begin
insert into report
select report_seq.nextval,service_id,mt_id,invite,sysdate-1/24,1 ,0 from(
  select service_id,mt_id,count(*) as invite from AIRTIME_INVITATION
  where log_time >= trunc(sysdate-1/24,'HH24') and log_time < trunc(sysdate,'HH24')
  group by service_id,mt_id
);
end;
2. Thêm vào job
BEGIN
DBMS_JOB.isubmit (
job => 179,
what => 'BEGIN PR_NOKIA_OVIA_INS; COMMIT; END;',
next_date => SYSDATE + 2/24,
interval => 'trunc(SYSDATE +1) + 2/24');
COMMIT;

END;

Không có nhận xét nào:

Đăng nhận xét