====== pears.NetClientPreviousEmployees ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create procedure "pears"."NetClientPreviousEmployees"( in "pWebUserID" char(20) ) result( "Name" char(100),"PersonID" char(20),"KeyName" char(100) ) begin declare local temporary table "Cos"( "CompanyID" char(20) null, ) not transactional; -- Get all the Companies the WebUser is Associated with declare local temporary table "Pes"( "PersonID" char(20) null, ) not transactional;insert into "Cos"( "CompanyID" ) select "companyid" from "employment" key join "iqxnetuserlink" where "iqxnetuserid" = "pWebUserID"; -- Get all the People who have worked in the period for those Companies insert into "Pes"( "PersonID" ) select distinct "e"."personid" from "employment" as "e" key join "placement" ,"employment" as "e" join "Cos" on "e"."CompanyID" = "Cos"."CompanyID" where not "e"."personid" = any(select "personid" from "employment" where "companyid" = "e"."companyid" and "noreemploy" = 1) and "e"."startdate" >= "IQXNetCompanyStartDate"("e"."companyid"); -- Get the Peoples details select "person"."name","person"."personid","person"."keyname" from "person" join "PES" on "Pes"."PersonID" = "Person"."PersonID" order by "person"."keyname" asc end go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetClientPreviousEmployees" IS {create procedure pears."NetClientPreviousEmployees"( in "pWebUserID" char(20) ) result( "Name" char(100),"PersonID" char(20),"KeyName" char(100) ) begin declare local temporary table "Cos"( "CompanyID" char(20) null, ) not transactional; -- Get all the Companies the WebUser is Associated with declare local temporary table "Pes"( "PersonID" char(20) null, ) not transactional;insert into "Cos"( "CompanyID" ) select "companyid" from "employment" key join "iqxnetuserlink" where "iqxnetuserid" = "pWebUserID"; -- Get all the People who have worked in the period for those Companies insert into "Pes"( "PersonID" ) select distinct "e"."personid" from "employment" as "e" key join "placement" ,"employment" as "e" join "Cos" on "e"."CompanyID" = "Cos"."CompanyID" where not "e"."personid" = any(select "personid" from "employment" where "companyid" = "e"."companyid" and "noreemploy" = 1) and "e"."startdate" >= "IQXNetCompanyStartDate"("e"."companyid"); -- Get the Peoples details select "person"."name","person"."personid","person"."keyname" from "person" join "PES" on "Pes"."PersonID" = "Person"."PersonID" order by "person"."keyname" asc end }