====== pears.IQXNetPopup ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."IQXNetPopup"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "pWebUserID" char(20),in "pPersonID" char(20),in "pEmploymentID" char(20),in "pVacancyID" char(20),in "pPlacementID" char(20),in "pProgressID" char(20),in "ptype" char(20),in "ptitle" char(100),in "pdescription" long varchar )
begin
declare "qstaffid" char(20);
declare "qpersonid" char(20);
declare "qemploymentid" char(20);
declare "qcompanyid" char(20);
declare "qvacancyid" char(20);
declare "qdivisionid" char(20);
declare "qdepartmentid" char(2);
declare "qlink" char(100);
declare "cnt" integer;
set "ptype" = "nullif"("trim"("ptype"),'');
set "ppersonid" = "nullif"("trim"("ppersonid"),'');
set "pemploymentid" = "nullif"("trim"("pemploymentid"),'');
set "pvacancyid" = "nullif"("trim"("pvacancyid"),'');
set "pplacementid" = "nullif"("trim"("pplacementid"),'');
set "pprogressid" = "nullif"("trim"("pprogressid"),'');
if "pPlacementID" is not null then
select "l"."staffid","pe"."personid","e"."employmentid","e"."companyid","l"."vacancyid","isnull"("p"."divisionid","c"."divisionid"),"v"."departmentid","string"('placement/',"pPlacementID")
into "qstaffid","qpersonid","qemploymentid","qcompanyid","qvacancyid","qdivisionid","qdepartmentid","qlink"
from "placement" as "l" key join "vacancy" as "v" key join "employment" as "e" key join "company" as "c","placement" as "l" key join "employment" as "pe" key join "person" as "p" where "l"."placementid" = "pPlacementID"
else if "pProgressID" is not null then
select "r"."staffid","r"."personid","e"."employmentid","e"."companyid","r"."vacancyid","isnull"("p"."divisionid","c"."divisionid"),"v"."departmentid","string"('progress/',"pProgressID")
into "qstaffid","qpersonid","qemploymentid","qcompanyid","qvacancyid","qdivisionid","qdepartmentid","qlink"
from "progress" as "r" key join "vacancy" as "v" key join "employment" as "e" key join "company" as "c","progress" as "r" key join "person" as "p" where "r"."progressid" = "pProgressID"
else if "pVacancyID" is not null then
select "v"."staffid","e"."employmentid","e"."companyid","v"."vacancyid","c"."divisionid","v"."departmentid","string"('vacancy/',"pVacancyID")
into "qstaffid","qemploymentid","qcompanyid","qvacancyid","qdivisionid","qdepartmentid","qlink"
from "vacancy" as "v" key join "employment" as "e" key join "company" as "c" where "v"."vacancyid" = "pVacancyID"
else if "pPersonID" is not null then
select "staffid","divisionid","string"('person/',"pPersonID")
into "qstaffid","qdivisionid","qlink"
from "person" where "personid" = "pPersonID"
end if end if end if end if;
set "ppersonid" = "isnull"("ppersonid","qpersonid");
set "pemploymentid" = "isnull"("pemploymentid","qemploymentid");
set "pvacancyid" = "isnull"("pvacancyid","qvacancyid");
if "ppersonid" is null and "pemploymentid" is null then
set "pemploymentid" = (select first "employmentid" from "iqxnetuserlink" where "iqxnetuserid" = "pwebuserid");
if "pemploymentid" is null then
set "ppersonid" = (select first "personid" from "iqxnetuserlink" where "iqxnetuserid" = "pwebuserid");
if "ppersonid" is null then
return
end if end if end if;
if "ptype" is not null then
call "RequestEmailStaffNotification"("ptype","string"("ptitle",'
',"pdescription"),"qLink","qDepartmentID","qDivisionID")
end if;
if "qcompanyid" is not null then
set "cnt" = 0;
for "fetchfor" as "fetchcursor" no scroll cursor for
select "staffid" as "xstaffid","isnull"("trim"("MessageType"),'') as "xtype" from "IQXNetMessageCompanyRecipient" where "companyid" = "qcompanyid" and("xtype" = '' or "xtype" = "ptype") for read only do
insert into "diary"( "diaryid","staffid","personid","employmentid","vacancyid","placementid","progressid","diaryfrom","description","notes","durationtype","popupminutes" ) values
( "uniquekey"("xstaffid"),"xstaffid","pPersonID","pEmploymentID","pVacancyID","pPlacementID","pProgressID",current timestamp,"ptitle","pdescription",'R',0 ) ;
set "cnt" = "cnt"+1 end for;
if "cnt" > 0 then
return
end if end if;
if "ptype" is not null then
set "qstaffid" = "isnull"((select first "staffid" from "IQXNetMessageRecipient" where "MessageType" = "ptype"),"qstaffid")
end if;
if "qstaffid" is null then
return
end if;
insert into "diary"( "diaryid","staffid","personid","employmentid","vacancyid","placementid","progressid","diaryfrom","description","notes","durationtype","popupminutes" ) values
( "uniquekey"(''),"qstaffid","pPersonID","pEmploymentID","pVacancyID","pPlacementID","pProgressID",current timestamp,"ptitle","pdescription",'R',0 )
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."IQXNetPopup" IS
{create procedure IQXNetPopup
/* Application Maintained Function / Procedure - DO NOT EDIT*/
( in pWebUserID char(20),in pPersonID char(20),in pEmploymentID char(20),in pVacancyID char(20),in pPlacementID char(20),in pProgressID char(20),in ptype char(20),in ptitle char(100),in pdescription long varchar )
begin
declare qstaffid char(20);
declare qpersonid char(20);
declare qemploymentid char(20);
declare qcompanyid char(20);
declare qvacancyid char(20);
declare qdivisionid char(20);
declare qdepartmentid char(2);
declare qlink char(100);
declare cnt integer;
set ptype = nullif(trim(ptype),'');
set ppersonid = nullif(trim(ppersonid),'');
set pemploymentid = nullif(trim(pemploymentid),'');
set pvacancyid = nullif(trim(pvacancyid),'');
set pplacementid = nullif(trim(pplacementid),'');
set pprogressid = nullif(trim(pprogressid),'');
if pPlacementID is not null then
select l.staffid,pe.personid,e.employmentid,e.companyid,l.vacancyid,isnull(p.divisionid,c.divisionid),v.departmentid,string('placement/',pPlacementID)
into qstaffid,qpersonid,qemploymentid,qcompanyid,qvacancyid,qdivisionid,qdepartmentid,qlink
from placement as l key join vacancy as v key join employment as e key join company as c,placement as l key join employment as pe key join person as p where l.placementid = pPlacementID
else if pProgressID is not null then
select r.staffid,r.personid,e.employmentid,e.companyid,r.vacancyid,isnull(p.divisionid,c.divisionid),v.departmentid,string('progress/',pProgressID)
into qstaffid,qpersonid,qemploymentid,qcompanyid,qvacancyid,qdivisionid,qdepartmentid,qlink
from progress as r key join vacancy as v key join employment as e key join company as c,progress as r key join person as p where r.progressid = pProgressID
else if pVacancyID is not null then
select v.staffid,e.employmentid,e.companyid,v.vacancyid,c.divisionid,v.departmentid,string('vacancy/',pVacancyID)
into qstaffid,qemploymentid,qcompanyid,qvacancyid,qdivisionid,qdepartmentid,qlink
from vacancy as v key join employment as e key join company as c where v.vacancyid = pVacancyID
else if pPersonID is not null then
select staffid,divisionid,string('person/',pPersonID)
into qstaffid,qdivisionid,qlink
from person where personid = pPersonID
end if
end if
end if end if;
set ppersonid = isnull(ppersonid,qpersonid);
set pemploymentid = isnull(pemploymentid,qemploymentid);
set pvacancyid = isnull(pvacancyid,qvacancyid);
if ppersonid is null and pemploymentid is null then
set pemploymentid = (select first employmentid from iqxnetuserlink where iqxnetuserid = pwebuserid);
if pemploymentid is null then
set ppersonid = (select first personid from iqxnetuserlink where iqxnetuserid = pwebuserid);
if ppersonid is null then
return
end if
end if end if;
if ptype is not null then
call RequestEmailStaffNotification(ptype,string(ptitle,'
',pdescription),qLink,qDepartmentID,qDivisionID)
end if;
if qcompanyid is not null then
set cnt = 0;
for fetchfor as fetchcursor no scroll cursor for
select staffid as xstaffid,isnull(trim(MessageType),'') as xtype from IQXNetMessageCompanyRecipient where companyid = qcompanyid and(xtype = '' or xtype = ptype) for read only do
insert into diary( diaryid,staffid,personid,employmentid,vacancyid,placementid,progressid,diaryfrom,description,notes,durationtype,popupminutes ) values
( uniquekey(xstaffid),xstaffid,pPersonID,pEmploymentID,pVacancyID,pPlacementID,pProgressID,current timestamp,ptitle,pdescription,'R',0 ) ;
set cnt = cnt+1 end for;
if cnt > 0 then
return
end if end if;
if ptype is not null then
set qstaffid = isnull((select first staffid from IQXNetMessageRecipient where MessageType = ptype),qstaffid)
end if;
if qstaffid is null then
return
end if;
insert into diary( diaryid,staffid,personid,employmentid,vacancyid,placementid,progressid,diaryfrom,description,notes,durationtype,popupminutes ) values
( uniquekey(''),qstaffid,pPersonID,pEmploymentID,pVacancyID,pPlacementID,pProgressID,current timestamp,ptitle,pdescription,'R',0 )
end
}