Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.NetCandidateProfileSet ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> create procedure "pears"."NetCandidateProfileSet"( in "pWebUserID" char(20),in "ppersonid" char(20),in "pForenames" char(50) default 'NOT-SET',in "pSurname" char(50) default 'NOT-SET',in "pGender" char(20) default 'NOT-SET',in "pdob" char(20) default 'NOT-SET',in "phomephone" char(250) default 'NOT-SET',in "pDayPhone" char(250) default 'NOT-SET',in "pMobile" char(250) default 'NOT-SET',in "pemail" char(250) default 'NOT-SET',in "pAddr1" char(50) default 'NOT-SET',in "pAddr2" char(50) default 'NOT-SET',in "pAddr3" char(50) default 'NOT-SET',in "pTown" char(50) default 'NOT-SET',in "pCounty" char(50) default 'NOT-SET',in "pCountry" char(50) default 'NOT-SET',in "pPostcode" char(50) default 'NOT-SET',in "pNINumber" char(20) default 'NOT-SET',in "pLoginID" char(50) default 'NOT-SET',in "pOLDForenames" char(50) default 'NOT-SET',in "pOLDSurname" char(50) default 'NOT-SET',in "pOLDGender" char(20) default 'NOT-SET',in "pOLDdob" char(20) default 'NOT-SET',in "pOLDhomephone" char(250) default 'NOT-SET',in "pOLDDayPhone" char(250) default 'NOT-SET',in "pOLDMobile" char(250) default 'NOT-SET',in "pOLDemail" char(250) default 'NOT-SET',in "pOLDAddr1" char(50) default 'NOT-SET',in "pOLDAddr2" char(50) default 'NOT-SET',in "pOLDAddr3" char(50) default 'NOT-SET',in "pOLDTown" char(50) default 'NOT-SET',in "pOLDCounty" char(50) default 'NOT-SET',in "pOLDCountry" char(50) default 'NOT-SET',in "pOLDPostcode" char(50) default 'NOT-SET',in "pOLDNINumber" char(20) default 'NOT-SET',in "pOLDLoginID" char(50) default 'NOT-SET', in "qanswers" long varchar default null, in "pSecondaryAgencyRef" char(100) default null,in "pSecondaryAgencyCandidateStatus" char(1) default null,in "pOptInToMarketing" tinyint default null ) result( "pResult" char(250) ) // IQXWeb begin declare "dateofbirth" date; declare "bnamechanged" smallint; declare "sname1" char(50); declare "fname1" char(50); declare "ssql" char(2048); declare "CompressedNI" char(20); set "bnamechanged" = 0; set "sname1" = 'surname'; set "fname1" = 'forenames'; set "CompressedNI" = "replace"("pNINumber",' ',''); set "ssql" = ''; if("NetHasPermission"("pWebUserID","pPersonID",null)+(select "count"() from "iqxnetuser" where "iqxnetuserid" = "pwebuserid" and "iqxnetuserclassid" = 'OWNER')) = 0 then select '99:~Permission denied'; return end if; if "isnull"("pforenames",'') <> "isnull"("poldforenames",'') then set "ssql" = "ssql"+',forenames=pforenames'; set "ssql" = "ssql"+',salutation=getword(pforenames,1)'; set "bnamechanged" = 1; set "fname1" = 'pforenames' end if; if "isnull"("psurname",'') <> "isnull"("poldsurname",'') then set "ssql" = "ssql"+',surname=psurname'; set "bnamechanged" = 1; set "sname1" = 'psurname' end if; if "bnamechanged" = 1 then set "ssql" = "ssql"+',name=string(getword('+"fname1"+',1),'' '','+"sname1"+')'; set "ssql" = "ssql"+',keyname=makekeyname(string('+"sname1"+','' '','+"fname1"+'))' end if; if "isnull"("pgender",'') <> "isnull"("poldgender",'') then set "ssql" = "ssql"+',sex=pgender' end if; if "isnull"("pdob",'') <> "isnull"("pOLDdob",'') then set "dateofbirth" = "IQXNetStringToDate"("pdob"); if "trim"("isnull"("pdob",'')) <> '' and "dateofbirth" is null then select '1:~Invalid date of birth'; return end if; set "ssql" = "ssql"+',dob = dateofbirth' end if; if "isnull"("paddr1",'') <> "isnull"("poldaddr1",'') then set "ssql" = "ssql"+',addr1=paddr1' end if; if "isnull"("paddr2",'') <> "isnull"("poldaddr2",'') then set "ssql" = "ssql"+',addr2=paddr2' end if; if "isnull"("paddr3",'') <> "isnull"("poldaddr3",'') then set "ssql" = "ssql"+',addr3=paddr3' end if; if "isnull"("ptown",'') <> "isnull"("poldtown",'') then set "ssql" = "ssql"+',town=ptown' end if; if "isnull"("pcounty",'') <> "isnull"("poldcounty",'') and "isnull"("WPKMaintainGetSwitchValue"('INCCOUNTY','','L'),'N') <> 'N' then set "ssql" = "ssql"+',county=pcounty' end if; if "isnull"("pcountry",'') <> "isnull"("poldcountry",'') and "isnull"("WPKMaintainGetSwitchValue"('INCCOUNTRY','','L'),'N') <> 'N' then set "ssql" = "ssql"+',country=pcountry' end if; if "isnull"("ppostcode",'') <> "isnull"("poldpostcode",'') then set "ssql" = "ssql"+',postcode=ucase(ppostcode)' end if; if "isnull"("pNINumber",'') <> "isnull"("poldNINumber",'') then set "ssql" = "ssql"+',ni=ucase(CompressedNI)' end if; if "pOptInToMarketing" is not null then set "ssql" = "ssql"+',UnsubscribeToMarketing=(if isnull(pOptInToMarketing,0)=0 then 1 else 0 endif)' end if; if "ssql" <> '' then execute immediate 'update person set '+"stuff"("ssql",1,1,'')+' where personid=ppersonid' end if; if "isnull"("phomephone",'') <> "isnull"("pOLDhomephone",'') then call "setphone"('P','Home Telephone',"ppersonid","phomephone") end if; if "isnull"("pdayphone",'') <> "isnull"("pOLDdayphone",'') then call "setphone"('P','Day Telephone',"ppersonid","pdayphone") end if; if "isnull"("pmobile",'') <> "isnull"("pOLDmobile",'') then call "setphone"('P','Mobile',"ppersonid","pmobile") end if; if "isnull"("pemail",'') <> "isnull"("pOLDemail",'') then update "iqxnetuserlink" key join "iqxnetuser" set "iqxnetuser"."emailaddress" = "pemail" where "iqxnetuserlink"."personid" = "ppersonid"; call "setphone"('P','E-mail',"ppersonid","pemail") end if; if "pSecondaryAgencyRef" is not null then update "pay_employee" set "SecondaryAgencyRef" = "ucase"("pSecondaryAgencyRef") where "personid" = "pPersonID" end if; if "pSecondaryAgencyCandidateStatus" is not null then update "pay_employee" set "SecondaryAgencyCandidateStatus" = "pSecondaryAgencyCandidateStatus" where "personid" = "pPersonID" end if; call "IQXNetSaveQuestionnaire"("ppersonid","qanswers"); call "personrecordupdated"("ppersonid"); select '0:~Success' end /* DOC 2016-12-02 PC test and doc 2018-01-25 PC BR-13 and IW-371 add NI number to details and remove login details 2018-02-14 PC OP-30 allow consultants to view and edit details 2018-02-16 PC BR-21 remove spaces from NI number 2018-04-23 MHS IW-426 Added SecondaryAgencyCandidateStatus, changed param to pSecondaryAgencyRef and simplified tests 2018-05-17 GJ Added UnsubscribeToMarketing Support 2018-07-24 PC include improved error handler 2020-03-02 GJ Changed order of updating the email address so an error can be triggered before its saved. 2020-04-02 GJ Check the switch values in general settings for include county and include country Inputs: pWebUserID ppersonid pForenames pSurname pGender pdob phomephone pDayPhone pMobile pemail pAddr1 pAddr2 pAddr3 pTown pCounty pCountry pPostcode pLoginID pOLDForenames pOLDSurname pOLDGender pOLDdob pOLDhomephone pOLDDayPhone pOLDMobile pOLDemail pOLDAddr1 pOLDAddr2 pOLDAddr3 pOLDTown pOLDCounty pOLDCountry pOLDPostcode pOLDLoginID qanswers pSecondaryAgencyRef pSecondaryAgencyCandidateStatus pUnsubscribeToMarketing Outputs: pResult Tests: */ /* TEST call NetTestSetup(''); call NetCandidateProfileSet(pWebUserID='test.candidate',pPersonID='TEST',pForenames='Fred',pSurname='Bloggs'); select * from NetCandidateProfile('test.candidate'); expect Forenames=Fred, Surname=Bloggs; */ go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetCandidateProfileSet" IS {create PROCEDURE pears."NetCandidateProfileSet"( in pWebUserID char(20),in ppersonid char(20),in pForenames char(50) default 'NOT-SET',in pSurname char(50) default 'NOT-SET',in pGender char(20) default 'NOT-SET',in pdob char(20) default 'NOT-SET',in phomephone char(250) default 'NOT-SET',in pDayPhone char(250) default 'NOT-SET',in pMobile char(250) default 'NOT-SET',in pemail char(250) default 'NOT-SET',in pAddr1 char(50) default 'NOT-SET',in pAddr2 char(50) default 'NOT-SET',in pAddr3 char(50) default 'NOT-SET',in pTown char(50) default 'NOT-SET',in pCounty char(50) default 'NOT-SET',in pCountry char(50) default 'NOT-SET',in pPostcode char(50) default 'NOT-SET',in pNINumber char(20) default 'NOT-SET',in pLoginID char(50) default 'NOT-SET',in pOLDForenames char(50) default 'NOT-SET',in pOLDSurname char(50) default 'NOT-SET',in pOLDGender char(20) default 'NOT-SET',in pOLDdob char(20) default 'NOT-SET',in pOLDhomephone char(250) default 'NOT-SET',in pOLDDayPhone char(250) default 'NOT-SET',in pOLDMobile char(250) default 'NOT-SET',in pOLDemail char(250) default 'NOT-SET',in pOLDAddr1 char(50) default 'NOT-SET',in pOLDAddr2 char(50) default 'NOT-SET',in pOLDAddr3 char(50) default 'NOT-SET',in pOLDTown char(50) default 'NOT-SET',in pOLDCounty char(50) default 'NOT-SET',in pOLDCountry char(50) default 'NOT-SET',in pOLDPostcode char(50) default 'NOT-SET',in pOLDNINumber char(20) default 'NOT-SET',in pOLDLoginID char(50) default 'NOT-SET', in qanswers long varchar default null, in pSecondaryAgencyRef char(100) default null, in pSecondaryAgencyCandidateStatus char(1) default null, pOptInToMarketing tinyint default null ) result( pResult char(250) ) // IQXWeb begin declare dateofbirth date; declare bnamechanged smallint; declare sname1 char(50); declare fname1 char(50); declare ssql char(2048); declare CompressedNI char(20); set bnamechanged = 0; set sname1 = 'surname'; set fname1 = 'forenames'; set CompressedNI=replace("pNINumber",' ',''); set ssql = ''; if (NetHasPermission(pWebUserID,pPersonID,null)+ (select count() from iqxnetuser where iqxnetuserid=pwebuserid and iqxnetuserclassid='OWNER'))=0 then select '99:~Permission denied'; return end if; if isnull(pforenames,'') <> isnull(poldforenames,'') then set ssql = ssql+',forenames=pforenames'; set ssql = ssql+',salutation=getword(pforenames,1)'; set bnamechanged = 1; set fname1 = 'pforenames' end if; if isnull(psurname,'') <> isnull(poldsurname,'') then set ssql = ssql+',surname=psurname'; set bnamechanged = 1; set sname1 = 'psurname' end if; if bnamechanged = 1 then set ssql = ssql+',name=string(getword('+fname1+',1),'' '','+sname1+')'; set ssql = ssql+',keyname=makekeyname(string('+sname1+','' '','+fname1+'))' end if; if isnull(pgender,'') <> isnull(poldgender,'') then set ssql = ssql+',sex=pgender' end if; if isnull(pdob,'') <> isnull(pOLDdob,'') then set dateofbirth = IQXNetStringToDate(pdob); if trim(isnull(pdob,'')) <> '' and dateofbirth is null then select '1:~Invalid date of birth'; return end if; set ssql = ssql+',dob = dateofbirth' end if; if isnull(paddr1,'') <> isnull(poldaddr1,'') then set ssql = ssql+',addr1=paddr1' end if; if isnull(paddr2,'') <> isnull(poldaddr2,'') then set ssql = ssql+',addr2=paddr2' end if; if isnull(paddr3,'') <> isnull(poldaddr3,'') then set ssql = ssql+',addr3=paddr3' end if; if isnull(ptown,'') <> isnull(poldtown,'') then set ssql = ssql+',town=ptown' end if; if isnull(pcounty,'') <> isnull(poldcounty,'') AND isnull(WPKMaintainGetSwitchValue('INCCOUNTY', '', 'L'), 'N') <> 'N' then set ssql = ssql+',county=pcounty' end if; if isnull(pcountry,'') <> isnull(poldcountry,'') AND isnull(WPKMaintainGetSwitchValue('INCCOUNTRY', '', 'L'), 'N') <> 'N' then set ssql = ssql+',country=pcountry' end if; if isnull(ppostcode,'') <> isnull(poldpostcode,'') then set ssql = ssql+',postcode=ucase(ppostcode)' end if; if isnull(pNINumber,'') <> isnull(poldNINumber,'') then set ssql = ssql+',ni=ucase(CompressedNI)' end if; if pOptInToMarketing is not null then set ssql = ssql+',UnsubscribeToMarketing=(if isnull(pOptInToMarketing,0)=0 then 1 else 0 endif)' end if; if ssql <> '' then execute immediate 'update person set '+stuff(ssql,1,1,'')+' where personid=ppersonid' end if; if isnull(phomephone,'') <> isnull(pOLDhomephone,'') then call setphone('P','Home Telephone',ppersonid,phomephone) end if; if isnull(pdayphone,'') <> isnull(pOLDdayphone,'') then call setphone('P','Day Telephone',ppersonid,pdayphone) end if; if isnull(pmobile,'') <> isnull(pOLDmobile,'') then call setphone('P','Mobile',ppersonid,pmobile) end if; if isnull(pemail,'') <> isnull(pOLDemail,'') then update iqxnetuserlink key join iqxnetuser set iqxnetuser.emailaddress = pemail where iqxnetuserlink.personid = ppersonid; call setphone('P','E-mail',ppersonid,pemail) end if; if pSecondaryAgencyRef is not null then update pay_employee set SecondaryAgencyRef=ucase(pSecondaryAgencyRef) where personid=pPersonID; end if; if pSecondaryAgencyCandidateStatus is not null then update pay_employee set SecondaryAgencyCandidateStatus=pSecondaryAgencyCandidateStatus where personid=pPersonID; end if; call IQXNetSaveQuestionnaire(ppersonid,qanswers); call personrecordupdated(ppersonid); select '0:~Success' end /* DOC 2016-12-02 PC test and doc 2018-01-25 PC BR-13 and IW-371 add NI number to details and remove login details 2018-02-14 PC OP-30 allow consultants to view and edit details 2018-02-16 PC BR-21 remove spaces from NI number 2018-04-23 MHS IW-426 Added SecondaryAgencyCandidateStatus, changed param to pSecondaryAgencyRef and simplified tests 2018-05-17 GJ Added UnsubscribeToMarketing Support 2018-07-24 PC include improved error handler 2020-03-02 GJ Changed order of updating the email address so an error can be triggered before its saved. 2020-04-02 GJ Check the switch values in general settings for include county and include country Inputs: pWebUserID ppersonid pForenames pSurname pGender pdob phomephone pDayPhone pMobile pemail pAddr1 pAddr2 pAddr3 pTown pCounty pCountry pPostcode pLoginID pOLDForenames pOLDSurname pOLDGender pOLDdob pOLDhomephone pOLDDayPhone pOLDMobile pOLDemail pOLDAddr1 pOLDAddr2 pOLDAddr3 pOLDTown pOLDCounty pOLDCountry pOLDPostcode pOLDLoginID qanswers pSecondaryAgencyRef pSecondaryAgencyCandidateStatus pUnsubscribeToMarketing Outputs: pResult Tests: */ /* TEST call NetTestSetup(''); call NetCandidateProfileSet(pWebUserID='test.candidate',pPersonID='TEST',pForenames='Fred',pSurname='Bloggs'); select * from NetCandidateProfile('test.candidate'); expect Forenames=Fred, Surname=Bloggs; */ } </code> database/procedures/pears_netcandidateprofileset.txt Last modified: 2026/08/07 19:24by 127.0.0.1