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.SetQuestMultiSelection ====== <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"."SetQuestMultiSelection"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "stagloc" char(3),in "stagid" char(3),in "sparentid" char(20),in "svalue" long varchar ) begin declare "i" integer; declare "stagchoiceid" char(4); declare "x" char(4); declare "schoicevalue" long varchar; declare "stagtype" char(1); select "tagtype" into "stagtype" from "tag" where "tag"."taglocation" = "stagloc" and "tag"."tagid" = "stagid"; if "charindex"("char"(10),"svalue") > 0 then -- Do not want to risk having line feeds set "svalue" = "replace"("svalue","char"(10),'') end if; set "svalue" = "string"("svalue","char"(13),' '); -- Ensure it has trailing CR and some extra space so that STUFF does not return emptry string and fall over loop set "i" = "charindex"("char"(9),"svalue"); if "i" = 0 then return end if; set "stagchoiceid" = "trim"("left"("svalue","i"-1)); set "svalue" = "stuff"("svalue",1,"i",''); set "i" = "charindex"("char"(13),"svalue"); set "schoicevalue" = "left"("svalue","i"-1); set "svalue" = "stuff"("svalue",1,"i",''); if "stagchoiceid" <> '' then if "stagtype" <> 'Q' then call "setquestanswer"("stagloc","stagid","stagchoiceid","sparentid","schoicevalue") else -- Submenu question select "tagchoiceparentid" into "x" from "tagchoice" where "taglocation" = "stagloc" and "tagid" = "stagid" and "tagchoiceid" = "stagchoiceid"; if "x" is not null then -- Format is as per GetQuestMultiSelection (rather than that used by IQX) so need to rearrange if "schoicevalue" = '1' then set "schoicevalue" = "stagchoiceid" else set "schoicevalue" = '0' -- Should be 0 already if not 1 end if; set "stagchoiceid" = "x" end if; call "setquestanswer"("stagloc","stagid","schoicevalue","sparentid","stagchoiceid") end if end if end loop end go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."SetQuestMultiSelection" IS {create procedure SetQuestMultiSelection /* Application Maintained Function / Procedure - DO NOT EDIT*/ (in stagloc char(3),in stagid char(3),in sparentid char(20),in svalue long varchar) begin declare i integer; declare stagchoiceid char(4); declare x char(4); declare schoicevalue long varchar; declare stagtype char(1); select tagtype into stagtype from tag where tag.taglocation=stagloc and tag.tagid=stagid; if charindex("char"(10),svalue) > 0 then -- Do not want to risk having line feeds set svalue=replace(svalue,"char"(10),'') end if; set svalue=string(svalue,"char"(13),' '); -- Ensure it has trailing CR and some extra space so that STUFF does not return emptry string and fall over loop set i=charindex("char"(9),svalue); if i = 0 then return end if; set stagchoiceid=trim("left"(svalue,i-1)); set svalue=stuff(svalue,1,i,''); set i=charindex("char"(13),svalue); set schoicevalue="left"(svalue,i-1); set svalue=stuff(svalue,1,i,''); if stagchoiceid <> '' then if stagtype<>'Q' then call setquestanswer(stagloc,stagid,stagchoiceid,sparentid,schoicevalue) else -- Submenu question select tagchoiceparentid into x from tagchoice where taglocation=stagloc and tagid=stagid and tagchoiceid=stagchoiceid; if x is not null then -- Format is as per GetQuestMultiSelection (rather than that used by IQX) so need to rearrange if schoicevalue='1' then set schoicevalue=stagchoiceid else set schoicevalue='0' -- Should be 0 already if not 1 end if; set stagchoiceid=x; end if; call setquestanswer(stagloc,stagid,schoicevalue,sparentid,stagchoiceid) end if end if end loop end } </code> database/procedures/pears_setquestmultiselection.txt Last modified: 2026/08/07 19:24by 127.0.0.1