====== pears.NetOLEDocuments ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetOLEDocuments"( in "pWebUserID" char(20),in "pOwnerType" char(1),in "pOwnerID" char(20) )
result( "DocType" char(50),"DocDescription" char(50),"LastUpdate" timestamp,"DocumentID" char(20),"SortOrder" integer )
-- 20120821 standard document list
begin
declare "userClass" char(20);
set "userClass" = (select first "iqxnetuserclassid" from "iqxnetuser" where "iqxnetuserid" = "pWebUserID");
if "pownertype" = 'P' then -- Candidate docs
if "iqxnethaspermission"("pwebuserid",'DOCCANDDOWNLOAD') = 0 then
select null,null,null,null,null from "dummy" where 1 = 0;
return
end if;
if "userclass" = 'CANDIDATE' then -- Own published docs only
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "personid" from "iqxnetuserlink" where "personid" = "pownerid" and "iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Can see published docs for any candidate owned by the agency
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "person"."personid" from "person" key join "pay_employee" key join "company" as "agcomp" key join "employment" as "agemp" key join "iqxnetuserlink" as "l" where "person"."personid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Can see PUBLISHED docs for any candidate
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = "pownerid"
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if end if end if end if;
if "pownertype" = 'C' then -- Company docs
if "userclass" = 'CLIENT' or "userclass" = 'AGENCY' then -- Can see docs belonging to the company
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "e"."companyid" from "iqxnetuserlink" as "l" key join "employment" as "e" where "e"."companyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else -- Candidates can not presently access company docs
select null,null,null,null,null from "dummy" where 1 = 0
end if end if;
if "pownertype" = 'V' then -- Vacancy docs
if "userclass" = 'CANDIDATE' then -- Can access any vacancy for which short-listed
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."vacancyid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "progress" as "r" where "r"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Can access any vacancy cascaded to the agency
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "c"."vacancyid" from "iqxnetuserlink" as "l" key join "employment" key join "company" key join "cascadedvacancy" as "c" where "c"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- CLients own vacancies
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "v"."vacancyid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ve" key join "vacancy" as "v" where "v"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if end if end if end if;
if "pownertype" = 'L' then -- Placement docs
if "userclass" = 'CANDIDATE' then -- Candidates own placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "employment" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Agency candidates placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "employment" as "agemp" key join "company" as "agcomp" key join "pay_employee" key join "person" key join "employment" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Client's own placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ple" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if end if end if end if;
if "pownertype" = 'R' then -- Progress docs
if "userclass" = 'CANDIDATE' then -- Candidates own progress
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Agency candidates progress
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "employment" as "agemp" key join "company" as "agcomp" key join "pay_employee" key join "person" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Progress for clients vacancies
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ve" key join "vacancy" as "v" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if
end if
end if
end if
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOLEDocuments" IS
{create procedure pears."NetOLEDocuments"( in "pWebUserID" char(20),in "pOwnerType" char(1),in "pOwnerID" char(20) )
result( "DocType" char(50),"DocDescription" char(50),"LastUpdate" timestamp,"DocumentID" char(20),"SortOrder" integer )
-- 20120821 standard document list
begin
declare "userClass" char(20);
set "userClass" = (select first "iqxnetuserclassid" from "iqxnetuser" where "iqxnetuserid" = "pWebUserID");
if "pownertype" = 'P' then -- Candidate docs
if "iqxnethaspermission"("pwebuserid",'DOCCANDDOWNLOAD') = 0 then
select null,null,null,null,null from "dummy" where 1 = 0;
return
end if;
if "userclass" = 'CANDIDATE' then -- Own published docs only
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "personid" from "iqxnetuserlink" where "personid" = "pownerid" and "iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Can see published docs for any candidate owned by the agency
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "person"."personid" from "person" key join "pay_employee" key join "company" as "agcomp" key join "employment" as "agemp" key join "iqxnetuserlink" as "l" where "person"."personid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Can see PUBLISHED docs for any candidate
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = "pownerid"
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if
end if
end if end if;
if "pownertype" = 'C' then -- Company docs
if "userclass" = 'CLIENT' or "userclass" = 'AGENCY' then -- Can see docs belonging to the company
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "e"."companyid" from "iqxnetuserlink" as "l" key join "employment" as "e" where "e"."companyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else -- Candidates can not presently access company docs
select null,null,null,null,null from "dummy" where 1 = 0
end if end if;
if "pownertype" = 'V' then -- Vacancy docs
if "userclass" = 'CANDIDATE' then -- Can access any vacancy for which short-listed
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."vacancyid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "progress" as "r" where "r"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Can access any vacancy cascaded to the agency
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "c"."vacancyid" from "iqxnetuserlink" as "l" key join "employment" key join "company" key join "cascadedvacancy" as "c" where "c"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- CLients own vacancies
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "v"."vacancyid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ve" key join "vacancy" as "v" where "v"."vacancyid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if
end if
end if end if;
if "pownertype" = 'L' then -- Placement docs
if "userclass" = 'CANDIDATE' then -- Candidates own placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "employment" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Agency candidates placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "employment" as "agemp" key join "company" as "agcomp" key join "pay_employee" key join "person" key join "employment" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Client's own placements
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "pl"."placementid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ple" key join "placement" as "pl" where "pl"."placementid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if
end if
end if end if;
if "pownertype" = 'R' then -- Progress docs
if "userclass" = 'CANDIDATE' then -- Candidates own progress
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "person" as "p" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'AGENCY' then -- Agency candidates progress
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "employment" as "agemp" key join "company" as "agcomp" key join "pay_employee" key join "person" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else if "userclass" = 'CLIENT' then -- Progress for clients vacancies
select "documenttype"."description","oledocument"."description","isnull"("blobstore"."changedat","blobstore"."createdat"),"oledocument"."oledocumentid","isnull"("documenttype"."sortorder",0) as "ord"
from "oledocument" join "blobstore" on "blobstore"."id" = "oledocument"."oledocumentid" and "blobstore"."class" = 'O',"oledocument" key join "documenttype"
where "oledocument"."ownertype" = "pownertype" and("oledocument"."rawfile" = 1 or "blobstore"."zipped" = 2)
and "oledocument"."ownerid" = any(select "r"."progressid" from "iqxnetuserlink" as "l" key join "employment" as "e" key join "company" key join "employment" as "ve" key join "vacancy" as "v" key join "progress" as "r" where "r"."progressid" = "pownerid" and "l"."iqxnetuserid" = "pwebuserid")
and "blobstore"."publishtoweb" = 1
else
select null,null,null,null,null from "dummy" where 1 = 0
end if
end if
end if
end if
end
}