====== pears.WPKLocalSwitchValue ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."WPKLocalSwitchValue"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "SwitchID" char(20),in "SwitchLocation" char(20),in "SwitchSource" char(1),in "SwitchLocked" smallint,in "SwitchLocalisable" smallint )
returns long varchar
begin
declare "rv" long varchar;
set "rv" = null;
if "switchlocked" = 1 or "switchsource" not in( 'L','P' ) then -- Only unlocked Literal and Params switches can be over-ridden in this way
return "rv"
end if;
if "switchlocation" is not null and "switchlocalisable" = 1 then
select first "value" into "rv" from "wpkglobalswitchsetting" where "wpkglobalswitchid" = "switchid" and "location" = "switchlocation"
end if;
if "switchsource" = 'L' and "rv" is null then -- Params continue to have their global value stored in the params table
select first "value" into "rv" from "wpkglobalswitchsetting" where "wpkglobalswitchid" = "switchid" and "location" = 'Global'
end if;
return "rv"
end