====== pears.NetCandidateCreateRegistration ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetCandidateCreateRegistration"( in "pWebUserID" char(20),in "pForenames" char(60),in "pSurname" char(60),in "pAddr1" char(60),in "pAddr2" char(60) default null,in "pAddr3" char(60) default null,in "pTown" char(60) default null,in "pCounty" char(60) default null,in "pCountry" char(60) default null,in "pPostcode" char(60),in "pDOB" char(60),in "pEmail" char(60),in "pUsername" char(60),in "pPassword" char(60),in "pRepeatpassword" char(60),in "pDepartment" char(5),in "pDivision" char(20),in "pDeptQs" char(2048),in "pPersonQs" char(2048) )
result( "pResult" char(250) )
// IQXWeb
begin
declare "dateofbirth" date;
declare "ppersonid" char(20);
declare "pfirstname" char(50);
declare "pnewappnumber" integer;
declare "pnewstatus" char(1);
declare "pnewwebuserid" char(20);
declare "chained" char(3);
declare "pKey" char(255);
set "pKey" = 'TheCro55Key5-L111e51eaf';
set "dateofbirth" = "IQXNetStringToDate"("pdob");
if "trim"("isnull"("pdob",'')) <> '' and "dateofbirth" is null then
select '1:~Invalid date of birth';
return
end if;
if "dateofbirth" is not null and "ppostcode" is not null then
if exists(select * from "person" where "postcode" = "ppostcode" and "dob" = "dateofbirth" and "similar"("string"("pforenames",' ',"psurname"),"string"("forenames",' ',"surname")) >= 90) then
select '2:~You may already be registered - please contact the agency';
return
end if end if;
set "pnewwebuserid" = "uniquekey"('');
set "chained" = (select "connection_property"('chained'));
set "ppersonid" = "uniquekey"('');
set "pfirstname" = "getword"("pforenames",1);
if "chained" = 'On' then
begin atomic
update "params" set "nextappnumber" = "isnull"("nextappnumber",0)+1 where "autoappnumber" = 1;
if @@rowcount > 0 then
set "pnewappnumber" = (select top 1 "nextappnumber" from "params" order by "dbid" asc)
else
set "pnewappnumber" = null
end if
end
else update "params" set "nextappnumber" = "isnull"("nextappnumber",0)+1 where "autoappnumber" = 1;
if @@rowcount > 0 then
set "pnewappnumber" = (select top 1 "nextappnumber" from "params" order by "dbid" asc)
else
set "pnewappnumber" = null
end if end if;
set "pnewstatus" = (select top 1 "initialapplicantstatus" from "params" order by "dbid" asc);
set "pnewstatus" = "isnull"("pnewstatus",'C');
insert into "person"( "personid","forenames","surname","name","keyname","salutation","dob","addr1","addr2","addr3","town","county","country","postcode","appnumber","status","registrationdate","divisionid" ) values
( "ppersonid","pforenames","psurname","string"("pfirstname",' ',"psurname"),"makekeyname"("string"("psurname",' ',"pforenames")),
"pfirstname","dateofbirth","paddr1","paddr2","paddr3","ptown","pcounty","pcountry","ucase"("ppostcode"),"pnewappnumber","pnewstatus",current date,"pDivision" ) ;
call "personrecordupdated"("ppersonid");
insert into "iqxnetuser"( "iqxnetuserid","iqxnetuserclassid","name","loginid","password","emailaddress","passwordset" ) values( "pnewwebuserid",'CANDIDATE',"string"("pfirstname",' ',"psurname"),"pEmail","encrypt"("pPassword","pKey"),"pEmail",1 ) ;
insert into "iqxnetuserlink"( "iqxnetuserlinkid","iqxnetuserid","personid" ) values( "ppersonid","pnewwebuserid","ppersonid" ) ;
if "pemail" is not null then
call "setphone"('P','E-mail',"ppersonid","pemail")
end if;
call "IQXNetSaveQuestionnaire"("ppersonid","pPersonQs");
call "IQXNetSaveQuestionnaire"("ppersonid","pDeptQs");
insert into "search"( "searchid","temp","permanent","personid","departmentid" ) values( "uniquekey"(''),1,0,"ppersonid","pdepartment" ) ;
insert into "IQXNetAction"( "IQXNetActionID","IQXNetUserID","ActionType","TargetType","ActionState","WhenRequested","TargetID","ActionAddress" ) values( "uniquekey"(''),"pnewwebuserid",'NotifyWebLoginCreated','P',0,current timestamp,"ppersonid","pEmail" ) ;
select '0:~Success'
end /* DOC
20170823 PC create candidate registration custom
2019-03-05 PC IW-873 add top 1 and order by on subqueries
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetCandidateCreateRegistration" IS
{create PROCEDURE pears."NetCandidateCreateRegistration"(in pWebUserID char(20),in pForenames char(60),in pSurname char(60),in pAddr1 char(60),in pAddr2 char(60) default null,in pAddr3 char(60) default null,in pTown char(60) default null,in pCounty char(60) default null,in pCountry char(60) default null,in pPostcode char(60),in pDOB char(60),in pEmail char(60),in pUsername char(60),in pPassword char(60),in pRepeatpassword char(60),in pDepartment char(5),in pDivision char(20),in pDeptQs char(2048),in pPersonQs char(2048))
RESULT(pResult char(250))
// IQXWeb
BEGIN
declare dateofbirth date;
declare "ppersonid" char(20);
declare "pfirstname" char(50);
declare "pnewappnumber" integer;
declare "pnewstatus" char(1);
declare "pnewwebuserid" char(20);
declare "chained" char(3);
declare pKey char(255);
set pKey = 'TheCro55Key5-L111e51eaf';
set dateofbirth=IQXNetStringToDate(pdob);
if trim(isnull(pdob,'')) <> '' and dateofbirth is null then
select '1:~Invalid date of birth';
return
end if;
if dateofbirth is not null and ppostcode is not null then
if exists(select * from person where postcode = ppostcode and dob = dateofbirth and similar(string(pforenames,' ',psurname),string(forenames,' ',surname)) >= 90) then
select '2:~You may already be registered - please contact the agency';
return
end if
end if;
set pnewwebuserid = "uniquekey"('');
set "chained" = (select "connection_property"('chained'));
set "ppersonid" = "uniquekey"('');
set "pfirstname" = "getword"("pforenames",1);
if "chained" = 'On' then
begin atomic
update "params" set "nextappnumber" = "isnull"("nextappnumber",0)+1 where "autoappnumber" = 1;
if @@rowcount > 0 then
set "pnewappnumber" = (select top 1 "nextappnumber" from "params" order by dbid)
else
set "pnewappnumber" = null
end if
end
else update "params" set "nextappnumber" = "isnull"("nextappnumber",0)+1 where "autoappnumber" = 1;
if @@rowcount > 0 then
set "pnewappnumber" = (select top 1 "nextappnumber" from "params" order by dbid)
else
set "pnewappnumber" = null
end if end if;
set "pnewstatus" = (select top 1 "initialapplicantstatus" from "params" order by dbid);
set "pnewstatus" = "isnull"("pnewstatus",'C');
insert into "person"( "personid","forenames","surname","name","keyname","salutation","dob","addr1","addr2","addr3","town","county","country","postcode","appnumber","status","registrationdate","divisionid" ) values
( "ppersonid","pforenames","psurname","string"("pfirstname",' ',"psurname"),"makekeyname"("string"("psurname",' ',"pforenames")),
"pfirstname","dateofbirth","paddr1","paddr2","paddr3","ptown","pcounty","pcountry","ucase"("ppostcode"),"pnewappnumber","pnewstatus",current date,pDivision ) ;
call "personrecordupdated"("ppersonid");
insert into iqxnetuser (iqxnetuserid,iqxnetuserclassid,name,loginid,password,emailaddress,passwordset) values (pnewwebuserid,'CANDIDATE',"string"("pfirstname",' ',"psurname"),pEmail,encrypt(pPassword,pKey),pEmail,1);
insert into "iqxnetuserlink"( "iqxnetuserlinkid","iqxnetuserid","personid" ) values( "ppersonid","pnewwebuserid","ppersonid" ) ;
if "pemail" is not null then
call "setphone"('P','E-mail',"ppersonid","pemail")
end if;
call "IQXNetSaveQuestionnaire"("ppersonid","pPersonQs");
call "IQXNetSaveQuestionnaire"("ppersonid","pDeptQs");
insert into search (searchid,temp,permanent,personid,departmentid) values ("uniquekey"(''),1,0,ppersonid,pdepartment);
insert into IQXNetAction (IQXNetActionID,IQXNetUserID,ActionType,TargetType,ActionState,WhenRequested,TargetID,ActionAddress) values (uniquekey(''),pnewwebuserid,'NotifyWebLoginCreated','P',0,current timestamp,ppersonid,pEmail);
select '0:~Success'
END
/* DOC
20170823 PC create candidate registration custom
2019-03-05 PC IW-873 add top 1 and order by on subqueries
*/
}