====== pears.NetWizardGetPage ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetWizardGetPage"( in "pWebUserID" char(20) default null,in "pWizardID" char(20) default null,in "pPath" long varchar default null,in "pAction" char(20) )
result( "pageID" char(50),"pageCaption" char(250),"pageFooter" char(250),"hasCheckBox" smallint,"isLastPage" smallint,"nextButtonCaption" char(100),"backButtonCaption" char(100),"pageNumber" smallint,"pageCount" smallint,"path" long varchar,"divisionEtc" char(100) )
begin
declare "sID" char(50);
declare "sPath" long varchar;
declare "i" smallint;
declare "iFirst" smallint;
declare "iLast" smallint;
declare "sFooter" char(250);
declare "iCheckbox" smallint;
// pAction values- start, resume, back, next
if "isnull"("pWebUserID",'') = '' then
set "pWebUserID" = null
end if;
if "isnull"("pWizardID",'') = '' then
set "pWizardID" = 'DEFAULT'
end if;
if "pAction" = 'start' then
set "sID" = "SoftWizardController"("pWizardID",null,'nextPageID');
if "sID" is not null then
set "sID" = "string"(':',"sID");
set "sPath" = "string"('/',"sID")
end if
else if "pAction" = 'resume' then
set "sPath" = (select "path" from "IQXNetWizardState" where "IQXNetUserID" = "pWebUserID" and "WizardID" = "pWizardID");
set "i" = "locate"("sPath",'/',-1);
if "isnull"("i",0) > 0 then
set "sID" = "substring"("sPath","i"+1)
else // No saved state - behave as start
set "sID" = "SoftWizardController"("pWizardID",null,'nextPageID');
if "sID" is not null then
set "sID" = "string"(':',"sID");
set "sPath" = "string"('/',"sID")
end if
end if
else if "pAction" = 'next' then
set "i" = "locate"("pPath",'/',-1);
if "isnull"("i",0) > 0 then
set "sID" = "substring"("pPath","i"+1);
set "sID" = "SoftWizardController"("pWizardID","replace"("sID",':',''),'nextPageID');
if "sID" is not null then
set "sPath" = "string"("pPath",'/',"sID")
end if
end if
else if "pAction" = 'back' then
set "i" = "locate"("pPath",'/',-1);
if "isnull"("i",0) > 0 then
set "sPath" = "substring"("pPath",1,"i"-1);
set "i" = "locate"("sPath",'/',-1);
if "isnull"("i",0) > 0 then
set "sID" = "substring"("sPath","i"+1)
end if
end if
end if
end if end if end if;
set "sID" = "isnull"("sID",'');
set "iFirst" = if "left"("sID",1) = ':' then 1 else 0 endif;
set "iLast" = if "right"("sID",1) = ':' then 1 else 0 endif;
set "sID" = "replace"("sID",':','');
if "sID" = '' then
select '',null,null,null,null,null,null,null,null,null,null
else
if "pWebUserID" is not null then
insert into "IQXNetWizardState"( "WizardID","IQXNetUserID","Path" ) on existing update defaults off values( "pWizardID","pWebUserID","sPath" )
end if;
set "sFooter" = "SoftWizardController"("pWizardID","sID",'pageFooter');
if "left"("sFooter",1) = '!' then
set "iCheckbox" = 1;
set "sFooter" = "stuff"("sFooter",1,1,'')
else
set "iCheckbox" = 0
end if;
select "sID",
"SoftWizardController"("pWizardID","sID",'pageCaption'),
"sFooter",
"iCheckbox",
"iLast",
if "iLast" = 1 then "isnull"("SoftWizardController"("pWizardID","sID",'finishButtonCaption'),'Finish') else "isnull"("SoftWizardController"("pWizardID","sID",'nextButtonCaption'),'Next') endif,
if "iFirst" = 1 then null else "isnull"("SoftWizardController"("pWizardID","sID",'backButtonCaption'),'Back') endif,
cast("isnull"("SoftWizardController"("pWizardID","sID",'pageNumber'),'0') as smallint),
cast("isnull"("SoftWizardController"("pWizardID","sID",'totalPageCount'),'0') as smallint),
"isnull"("sPath",''),"isnull"("SoftWizardController"("pWizardID","sID",'division'),'')
end if
end /* DOC
2019-03-20 MHS. Controlling proc for delivery of soft wizard mechanism.
*/
/* TEST
select *,ifnull(backButtonCaption,'null','notnull') as bb from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1/page2/page3:/page4', 'back');
expect pageID=page3, path=/page1/page2/page3:, isLastPage=1, bb=notnull;
select *,ifnull(backButtonCaption,'null','notnull') as bb from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1/page2/:page3/page4', 'back');
expect pageID=page3, path=/page1/page2/:page3, isLastPage=0, bb=null;
select * from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD','', 'resume');
expect pageID=page3, path=/page1/page2/:page3;
select *,string(pageID,'X') as p1, string(path,'Y') as p2 from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1', 'back');
expect p1=X, p2=Y;
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetWizardGetPage" IS
{create PROCEDURE pears."NetWizardGetPage"(in pWebUserID char(20) default null, in pWizardID char(20) default null, in pPath long varchar default null, in pAction char(20) )
RESULT(pageID char(50), pageCaption char(250), pageFooter char(250), hasCheckBox smallint, isLastPage smallint, nextButtonCaption char(100), backButtonCaption char(100), pageNumber smallint, pageCount smallint, path long varchar, divisionEtc char(100) )
BEGIN
declare sID char(50);
declare sPath long varchar;
declare i smallint;
declare iFirst smallint;
declare iLast smallint;
declare sFooter char(250);
declare iCheckbox smallint;
// pAction values- start, resume, back, next
if isnull(pWebUserID,'')='' then
set pWebUserID=null
end if;
if isnull(pWizardID,'')='' then
set pWizardID='DEFAULT'
end if;
if pAction='start' then
set sID = SoftWizardController(pWizardID, null, 'nextPageID');
if sID is not null then
set sID=string(':',sID);
set sPath = string('/',sID);
end if;
else if pAction='resume' then
set sPath=(select path from IQXNetWizardState where IQXNetUserID=pWebUserID and WizardID=pWizardID);
set i=locate(sPath,'/',-1);
if isnull(i,0)>0 then
set sID=substring(sPath,i+1);
else // No saved state - behave as start
set sID = SoftWizardController(pWizardID, null, 'nextPageID');
if sID is not null then
set sID=string(':',sID);
set sPath = string('/',sID);
end if;
end if;
else if pAction='next' then
set i=locate(pPath,'/',-1);
if isnull(i,0)>0 then
set sID=substring(pPath,i+1);
set sID=SoftWizardController(pWizardID, replace(sID,':',''), 'nextPageID');
if sID is not null then
set sPath=string(pPath,'/',sID);
end if;
end if;
else if pAction='back' then
set i=locate(pPath,'/',-1);
if isnull(i,0)>0 then
set sPath=substring(pPath,1,i-1);
set i=locate(sPath,'/',-1);
if isnull(i,0)>0 then
set sID=substring(sPath,i+1);
end if;
end if;
end if;
end if;
end if;
end if;
set sID=isnull(sID,'');
set iFirst=if left(sID,1)=':' then 1 else 0 endif;
set iLast=if right(sID,1)=':' then 1 else 0 endif;
set sID=replace(sID,':','');
if sID='' then
select '', null, null, null, null, null, null, null, null, null, null
else
if pWebUserID is not null then
insert into IQXNetWizardState (WizardID,IQXNetUserID,Path) on existing update defaults off values (pWizardID,pWebUserID,sPath);
end if;
set sFooter=SoftWizardController(pWizardID,sID,'pageFooter');
if left(sFooter,1)='!' then
set iCheckbox=1;
set sFooter=stuff(sFooter,1,1,'');
else
set iCheckbox=0;
end if;
select sID,
SoftWizardController(pWizardID,sID,'pageCaption'),
sFooter,
iCheckbox,
iLast,
if iLast=1 then isnull(SoftWizardController(pWizardID,sID,'finishButtonCaption'),'Finish') else isnull(SoftWizardController(pWizardID,sID,'nextButtonCaption'),'Next') endif,
if iFirst=1 then null else isnull(SoftWizardController(pWizardID,sID,'backButtonCaption'),'Back') endif,
cast(isnull(SoftWizardController(pWizardID,sID,'pageNumber'),'0') as smallint),
cast(isnull(SoftWizardController(pWizardID,sID,'totalPageCount'),'0') as smallint),
isnull(sPath,''), isnull(SoftWizardController(pWizardID,sID,'division'),'');
end if;
END
/* DOC
2019-03-20 MHS. Controlling proc for delivery of soft wizard mechanism.
*/
/* TEST
select *,ifnull(backButtonCaption,'null','notnull') as bb from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1/page2/page3:/page4', 'back');
expect pageID=page3, path=/page1/page2/page3:, isLastPage=1, bb=notnull;
select *,ifnull(backButtonCaption,'null','notnull') as bb from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1/page2/:page3/page4', 'back');
expect pageID=page3, path=/page1/page2/:page3, isLastPage=0, bb=null;
select * from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD','', 'resume');
expect pageID=page3, path=/page1/page2/:page3;
select *,string(pageID,'X') as p1, string(path,'Y') as p2 from NetWizardGetPage('TEST.CANDIDATE', 'TESTWIZARD', '/page1', 'back');
expect p1=X, p2=Y;
*/
}