====== pears.TempShiftCancel ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."TempShiftCancel"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "TSPID" char(20),in "CancReasID" char(2),in "InNote" char(100) )
begin
declare "TSID" char(20);
declare @Bill integer;
declare @ClientAware integer;
declare @TempAware integer;
declare @Pay integer;
declare @Refill integer;
select first "tempshiftid" into "tsid" from "tempshift" where "tempshiftplanid" = "tspid" order by "isnull"("whencancelled","whenentered") desc;
select "Bill","ClientAware","TempAware","Pay","Refill" into @Bill,@ClientAware,@TempAware,@Pay,@Refill from "tempshiftcancelreason" where "tempshiftcancelreasonid" = "CancReasID";
if "TSID" > '' then
update "tempshift" set "state" = 'C',"cancelreason" = "CancReasID","whencancelled" = current timestamp,"whocancelled" = "userstaffid",
"clientconfirmed" = @ClientAware,"tempconfirmed" = @TempAware,"cbill" = @bill,"cpay" = @pay,"crefill" = @Refill,"Note" = "InNote" where "tempshiftid" = "TSID"
else
insert into "tempshift"( "tempshiftid","vacancyid","shiftdate","timefrom","timeto","state","note","tempshiftplanid","breakminutes","essentialskillgradeid",
"cancelreason","whencancelled","whocancelled","cbill","clientconfirmed","tempconfirmed","cpay","crefill","referencecode" ) select "uniquekey"(''''),"vacancyid","shiftdate","timefrom","timeto",'C',"InNote",
"tempshiftplanid","breakminutes","essentialskillgradeid","CancReasID",current timestamp,"userstaffid",@Bill,@ClientAware,1,0,0,"referencecode" from "tempshiftplan" where "tempshiftplanid" = "TSPID"
end if
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."TempShiftCancel" IS
{create procedure TempShiftCancel
/* Application Maintained Function / Procedure - DO NOT EDIT*/
( in TSPID char(20),in CancReasID char(2),in InNote char(100) )
begin
declare TSID char(20);
declare @Bill integer;
declare @ClientAware integer;
declare @TempAware integer;
declare @Pay integer;
declare @Refill integer;
select first tempshiftid into tsid from tempshift where tempshiftplanid = tspid order by isnull(whencancelled,whenentered) desc;
select Bill,ClientAware,TempAware,Pay,Refill into @Bill,@ClientAware,@TempAware,@Pay,@Refill from tempshiftcancelreason where tempshiftcancelreasonid = CancReasID;
if TSID > '' then
update tempshift set state = 'C',cancelreason = CancReasID,whencancelled = current timestamp,whocancelled = userstaffid,
clientconfirmed = @ClientAware,tempconfirmed = @TempAware,cbill = @bill,cpay = @pay,crefill = @Refill,Note = InNote where tempshiftid = TSID
else
insert into tempshift( tempshiftid,vacancyid,shiftdate,timefrom,timeto,state,note,tempshiftplanid,breakminutes,essentialskillgradeid,
cancelreason,whencancelled,whocancelled,cbill,clientconfirmed,tempconfirmed,cpay,crefill,referencecode ) select uniquekey(''''),vacancyid,shiftdate,timefrom,timeto,'C',InNote,
tempshiftplanid,breakminutes,essentialskillgradeid,CancReasID,current timestamp,userstaffid,@Bill,@ClientAware,1,0,0,referencecode from tempshiftplan where tempshiftplanid = TSPID
end if
end
}