====== pears.AutoMatchProcessShiftQueue ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."AutoMatchProcessShiftQueue"()
/* Application Maintained Function / Procedure - DO NOT EDIT*/
begin
create or replace variable "GlobalMaxEmails" integer;
create or replace variable "GlobalMaxSMS" integer;
create or replace variable "GlobalMaxPush" integer;
create or replace variable "GlobalMinEmailGap" integer;
create or replace variable "GlobalMinSMSGap" integer;
create or replace variable "GlobalMinPushGap" integer;
select first "MaxEmails","MaxSMS","MaxPush","MinDelayBetweenEmails","MinDelayBetweenSMS","MinDelayBetweenPush" into "GlobalMaxEmails",
"GlobalMaxSMS","GlobalMaxPush","GlobalMinEmailGap","GlobalMinSMSGap","GlobalMinPushGap" from "AutoMatchGlobalConfig";
for "s" as "tscursor" no scroll cursor for
select "AutoMatchShiftQueueID" as "QID","TempShiftPlanID" as "TPID","Created"
from(select "AutoMatchShiftQueueID","TempShiftPlanID","Created","max"("Created") over(partition by "TempShiftPlanID") as "maxCreate"
from "AutoMatchShiftQueue" where "NotRequired" = 0 and "Completed" is null) as "Shifts"
where "Created" = "maxCreate"
order by "TPID" asc for read only do
call "AutoMatchProcessShift"("TPID");
update "AutoMatchShiftQueue" set "completed" = current timestamp where "AutoMatchShiftQueueID" = "QID";
update "AutoMatchShiftQueue" set "NotRequired" = 1 where "AutoMatchShiftQueueID" <> "QID" and "Completed" is null and "TempShiftPlanID" = "TPID"
end for
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."AutoMatchProcessShiftQueue" IS
{create procedure AutoMatchProcessShiftQueue
/* Application Maintained Function / Procedure - DO NOT EDIT*/
()
begin
CREATE OR REPLACE VARIABLE GlobalMaxEmails integer;
CREATE OR REPLACE VARIABLE GlobalMaxSMS integer;
CREATE OR REPLACE VARIABLE GlobalMaxPush integer;
CREATE OR REPLACE VARIABLE GlobalMinEmailGap integer;
CREATE OR REPLACE VARIABLE GlobalMinSMSGap integer;
CREATE OR REPLACE VARIABLE GlobalMinPushGap integer;
select first MaxEmails, MaxSMS, MaxPush, MinDelayBetweenEmails, MinDelayBetweenSMS, MinDelayBetweenPush into GlobalMaxEmails,
GlobalMaxSMS, GlobalMaxPush, GlobalMinEmailGap, GlobalMinSMSGap, GlobalMinPushGap from AutoMatchGlobalConfig;
for s as tscursor no scroll cursor for
select AutoMatchShiftQueueID as QID, TempShiftPlanID as TPID, Created from
(select AutoMatchShiftQueueID, TempShiftPlanID, Created, max(Created) over (partition by TempShiftPlanID ) maxCreate
from AutoMatchShiftQueue where NotRequired = 0 and Completed is null) Shifts
where Created = maxCreate
order by TPID for read only do
call AutoMatchProcessShift(TPID);
update AutoMatchShiftQueue set completed = current timestamp where AutoMatchShiftQueueID = QID;
update AutoMatchShiftQueue set NotRequired = 1 where AutoMatchShiftQueueID <> QID and Completed is null and TempShiftPlanID = TPID;
end for;
end
}