====== pears.NetOwnerEmployeeEdit ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetOwnerEmployeeEdit"( in "pWebUserID" char(20),in "pObjID" char(20),in "pParentObject" char(20),in "pForenames" char(50) default null,in "pSurname" char(50) default null,in "pSalutation" char(50) default null,in "pDirect_Phone" char(50) default null,in "pMobile" char(50) default null,in "pEmail" char(50) default null,in "pDirect_Fax" char(50) default null,in "pPosition" char(50) default null,in "pDepartment" char(50) default null,in "pNotes" char(100) default null,
in "pOldForenames" char(50) default null,in "pOldSurname" char(50) default null,in "pOldSalutation" char(50) default null,in "pOldDirect_Phone" char(50) default null,in "pOldMobile" char(50) default null,in "pOldEmail" char(50) default null,in "pOldDirect_Fax" char(50) default null,in "pOldPosition" char(50) default null,in "pOldDepartment" char(50) default null,in "pOldNotes" char(100) default null )
result( "pResult" char(250) )
begin
declare "PersID" char(20);
declare "ssql" char(255);
declare "divid" char(20);
set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid");
if "divid" is null then
select '99:~Permission denied';
return
end if;
if "IQXNetHasPermission"("pWebUserID",'ADDCANDIDATES') = 0 then
select '99:~Permission denied';
return
end if;
if "pForenames" = '' or "pSurname" = '' then
select '101:~Please ensure there is both a Forename and a Surname';
return
end if;
if("pObjID" = '') then
set "PersID" = "uniquekey"("pForenames"+"pSurname");
insert into "person"( "personid","name","keyname","salutation","forenames","surname","status" ) values( "PersID","pForenames"+' '+"pSurname","ucase"("pForenames")+' '+"ucase"("pSurname"),"pSalutation","pForenames","pSurname",'C' ) ;
insert into "employment"( "employmentid","personid","companyid","temp" ) values( "PersID","PersID","pParentObject",'0' )
else
set "PersID" = "pObjID";
update "person" set "forenames" = "pForenames","surname" = "pSurname","name" = "pForenames"+' '+"pSurname","keyname" = "ucase"("pForenames")+' '+"ucase"("pSurname"),"salutation" = "pSalutation" where "personid" = "PersID"
end if;
if "pNotes" <> "pOldNotes" then
update "employment" set "note" = "pNotes" where "personid" = "PersID"
end if;
if "pPosition" <> "pOldPosition" then
update "employment" set "position" = "pPosition" where "personid" = "PersID"
end if;
if "pDepartment" <> "pOldDepartment" then
update "employment" set "department" = "pDepartment" where "personid" = "PersID"
end if;
if "pDirect_Phone" <> "pOldDirect_Phone" then
call "SetPhone"('CP','Direct Telephone',"PersID","pDirect_Phone")
end if;
if "pMobile" <> "pOldMobile" then
call "SetPhone"('CP','Mobile',"PersID","pMobile")
end if;
if "pEmail" <> "pOldEmail" then
call "SetPhone"('CP','E-mail',"PersID","pEmail")
end if;
if "pDirect_Fax" <> "pOldDirect_Fax" then
call "SetPhone"('CP','Direct Fax',"PersID","pDirect_Fax")
end if;
select "string"('0:',"PersID",'#',"pParentObject",'~Success')
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOwnerEmployeeEdit" IS
{create procedure pears."NetOwnerEmployeeEdit"( in "pWebUserID" char(20),in "pObjID" char(20),in "pParentObject" char(20),in "pForenames" char(50) default null,in "pSurname" char(50) default null,in "pSalutation" char(50) default null,in "pDirect_Phone" char(50) default null,in "pMobile" char(50) default null,in "pEmail" char(50) default null,in "pDirect_Fax" char(50) default null,in "pPosition" char(50) default null,in "pDepartment" char(50) default null,in "pNotes" char(100) default null,
in "pOldForenames" char(50) default null,in "pOldSurname" char(50) default null,in "pOldSalutation" char(50) default null,in "pOldDirect_Phone" char(50) default null,in "pOldMobile" char(50) default null,in "pOldEmail" char(50) default null,in "pOldDirect_Fax" char(50) default null,in "pOldPosition" char(50) default null,in "pOldDepartment" char(50) default null,in "pOldNotes" char(100) default null )
result( "pResult" char(250) )
begin
declare "PersID" char(20);
declare "ssql" char(255);
declare "divid" char(20);
set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid");
if "divid" is null then
select '99:~Permission denied';
return
end if;
if "IQXNetHasPermission"("pWebUserID",'ADDCANDIDATES') = 0 then
select '99:~Permission denied';
return
end if;
if "pForenames" = '' or "pSurname" = '' then
select '101:~Please ensure there is both a Forename and a Surname';
return
end if;
if("pObjID" = '') then
set "PersID" = "uniquekey"("pForenames"+"pSurname");
insert into "person"( "personid","name","keyname","salutation","forenames","surname","status" ) values( "PersID","pForenames"+' '+"pSurname","ucase"("pForenames")+' '+"ucase"("pSurname"),"pSalutation","pForenames","pSurname",'C' ) ;
insert into "employment"( "employmentid","personid","companyid","temp" ) values( "PersID","PersID","pParentObject",'0' )
else
set "PersID" = "pObjID";
update "person" set "forenames" = "pForenames","surname" = "pSurname","name" = "pForenames"+' '+"pSurname","keyname" = "ucase"("pForenames")+' '+"ucase"("pSurname"),"salutation" = "pSalutation" where "personid" = "PersID"
end if;
if "pNotes" <> "pOldNotes" then
update "employment" set "note" = "pNotes" where "personid" = "PersID"
end if;
if "pPosition" <> "pOldPosition" then
update "employment" set "position" = "pPosition" where "personid" = "PersID"
end if;
if "pDepartment" <> "pOldDepartment" then
update "employment" set "department" = "pDepartment" where "personid" = "PersID"
end if;
if "pDirect_Phone" <> "pOldDirect_Phone" then
call "SetPhone"('CP','Direct Telephone',"PersID","pDirect_Phone")
end if;
if "pMobile" <> "pOldMobile" then
call "SetPhone"('CP','Mobile',"PersID","pMobile")
end if;
if "pEmail" <> "pOldEmail" then
call "SetPhone"('CP','E-mail',"PersID","pEmail")
end if;
if "pDirect_Fax" <> "pOldDirect_Fax" then
call "SetPhone"('CP','Direct Fax',"PersID","pDirect_Fax")
end if;
select "string"('0:',"PersID",'#',"pParentObject",'~Success')
end
}