PR INS REGISTRY

Материал из wiki.standart-n.ru
Перейти к: навигация, поиск
 SET TERM ^ ;
  
  create or alter procedure PR_INS_REGISTRY (
      DOCTOR_ID DM_UUID_NULL)
  as
  declare variable TEMP_DATE DM_DATETIME;
  declare variable FIRST_DATE DM_DATETIME;
  declare variable RES_DATE DM_DATETIME;
  begin
  temp_date='01.01.2017 08:00:00';
  first_date='01.01.2017 08:00:00';
    while (temp_date<'01.01.2018 00:00:00')
    do
    begin
     res_date=temp_date;
     if ((select first 1 r.d$uuid from registry r where r.doctor_id=:doctor_id and
      r.status>-1 and r.reg_date=:res_date) is null) then
       INSERT INTO REGISTRY (DOCTOR_ID, STATUS, REG_DATE)
       VALUES (:doctor_id,0,:res_date);
     temp_date=dateadd(minute,30,temp_date);
     if (extract(hour from temp_date)=22 and extract(minute from temp_date)=00) then
     begin
       temp_date=first_date+1;
       first_date=temp_date;
     end
     --suspend;
    end
  end^
  
  SET TERM ; ^
  
  /* Following GRANT statetements are generated automatically */
  
  GRANT SELECT,INSERT ON REGISTRY TO PROCEDURE PR_INS_REGISTRY;
  
  /* Existing privileges on this procedure */
  
  GRANT EXECUTE ON PROCEDURE PR_INS_REGISTRY TO PROCEDURE TEMP;
  GRANT EXECUTE ON PROCEDURE PR_INS_REGISTRY TO SYSDBA;