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.WPKMaintainSetSwitchValue ====== <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"."WPKMaintainSetSwitchValue"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "SwitchID" char(20),in "SwitchLocation" char(20),in "SwitchSource" char(1),in "SwitchValue" long varchar ) begin declare "param" char(100); declare "x" long varchar; declare "i" smallint; declare "tp" char(1); declare "oldvalue" long varchar; declare "wname" char(100); if "switchsource" not in( 'L','P' ) then -- Only Literal and Params maintained in this way return end if; select "WPKMaintainGetSwitchValue"("switchid","switchlocation","switchsource") into "oldvalue"; set "switchlocation" = "trim"("switchlocation"); if "switchlocation" = 'Global' or "switchlocation" = '' then set "switchlocation" = null end if; if "switchlocation" is not null then delete from "wpkglobalswitchsetting" where "wpkglobalswitchid" = "switchid" and "location" = "switchlocation"; if "switchvalue" is not null then insert into "wpkglobalswitchsetting"( "wpkglobalswitchid","location","value" ) values( "switchid","switchlocation","switchvalue" ) end if else if "switchsource" = 'L' then delete from "wpkglobalswitchsetting" where "wpkglobalswitchid" = "switchid" and "location" = 'Global'; if "switchvalue" is not null then insert into "wpkglobalswitchsetting"( "wpkglobalswitchid","location","value" ) values( "switchid",'Global',"switchvalue" ) end if else select "value","datatype" into "x","tp" from "wpkglobalswitch" where "wpkglobalswitchid" = "switchid"; set "i" = "charindex"(';',"x"); if "i" > 0 then set "param" = "left"("x","i"-1) else set "param" = "x" end if; if "tp" = 'B' then if "ucase"("left"("trim"("switchvalue"),1)) in( '1','Y','T' ) then set "switchvalue" = '1' else set "switchvalue" = '0' end if end if; execute immediate with batch off "string"('update params set ',"param",'=switchvalue') end if end if; call "WPKTrackChange"('S','*'); select "name" into "wname" from "wpkglobalswitch" where "wpkglobalswitchid" = "switchid"; call "AuditLog"('SETTINGS',"switchid","wname","oldvalue","switchvalue") end go COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."WPKMaintainSetSwitchValue" IS {create procedure WPKMaintainSetSwitchValue /* Application Maintained Function / Procedure - DO NOT EDIT*/ (in SwitchID char(20),in SwitchLocation char(20),in SwitchSource char(1),in SwitchValue long varchar) begin declare param char(100); declare x long varchar; declare i smallint; declare tp char(1); declare oldvalue long varchar; declare wname char(100); if switchsource not in('L','P') then -- Only Literal and Params maintained in this way return end if; select WPKMaintainGetSwitchValue(switchid,switchlocation,switchsource) into oldvalue; set switchlocation=trim(switchlocation); if switchlocation = 'Global' or switchlocation = '' then set switchlocation=null end if; if switchlocation is not null then delete from wpkglobalswitchsetting where wpkglobalswitchid = switchid and location = switchlocation; if switchvalue is not null then insert into wpkglobalswitchsetting(wpkglobalswitchid,location,value) values(switchid,switchlocation,switchvalue) end if else if switchsource = 'L' then delete from wpkglobalswitchsetting where wpkglobalswitchid = switchid and location = 'Global'; if switchvalue is not null then insert into wpkglobalswitchsetting(wpkglobalswitchid,location,value) values(switchid,'Global',switchvalue) end if else select value,datatype into x,tp from wpkglobalswitch where wpkglobalswitchid = switchid; set i=charindex(';',x); if i > 0 then set param="left"(x,i-1) else set param=x end if; if tp = 'B' then if ucase("left"(trim(switchvalue),1)) in('1','Y','T') then set switchvalue='1' else set switchvalue='0' end if end if; execute immediate WITH BATCH OFF string('update params set ',param,'=switchvalue') end if end if; call WPKTrackChange('S','*'); select name into wname from wpkglobalswitch where wpkglobalswitchid = switchid; call AuditLog('SETTINGS', switchid,wname, oldvalue, switchvalue); end } </code> database/procedures/pears_wpkmaintainsetswitchvalue.txt Last modified: 2026/08/07 19:24by 127.0.0.1