pears.WPKMaintainGetSwitchValue

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."WPKMaintainGetSwitchValue" IS 
{CREATE FUNCTION WPKMaintainGetSwitchValue 
 
/* Application Maintained Function / Procedure - DO NOT EDIT*/
 
(IN SwitchID CHAR(20),IN SwitchLocation CHAR(20),IN SwitchSource CHAR(1))
RETURNS long VARCHAR
BEGIN
  DECLARE rv long VARCHAR;
  DECLARE param CHAR(100);
  DECLARE def long VARCHAR;
  DECLARE i SMALLINT;
  DECLARE tp CHAR(1);
  IF switchsource NOT IN('L','P') THEN -- Only Literal and Params maintained in this way
    RETURN NULL
  END IF;
  SET rv=NULL;
  SET switchlocation=TRIM(switchlocation);
  IF switchlocation = 'Global' OR switchlocation = '' THEN
    SET switchlocation=NULL
  END IF;
  IF switchlocation IS NOT NULL THEN -- For maintenance we are just interested in the branch setting - we do NOT fall back to the global
    SELECT FIRST VALUE INTO rv FROM wpkglobalswitchsetting WHERE wpkglobalswitchid = switchid AND location = switchlocation
  ELSE
    IF switchsource = 'L' THEN
      SELECT FIRST VALUE INTO rv FROM wpkglobalswitchsetting WHERE wpkglobalswitchid = switchid AND location = 'Global';
      IF rv IS NULL THEN
        SELECT VALUE INTO rv FROM wpkglobalswitch WHERE wpkglobalswitchid = switchid
      END IF
    ELSE
      SELECT VALUE INTO def FROM wpkglobalswitch WHERE wpkglobalswitchid = switchid;
      SET i=charindex(';',def);
      IF i > 0 THEN
        SET param="left"(def,i-1);
        SET def="right"(def,LENGTH(def)-i)
      ELSE
        SET param=def;
        SET def=NULL
      END IF;
      EXECUTE IMMEDIATE WITH BATCH OFF string('select first ',param,' into rv from params');
      IF TRIM(isnull(rv,'')) = '' THEN
        SET rv=def
      END IF
    END IF
  END IF;
  IF TRIM(isnull(rv,'')) <> '' THEN
    SELECT datatype INTO tp FROM wpkglobalswitch WHERE wpkglobalswitchid = switchid;
    IF tp = 'B' THEN
      IF ucase("left"(TRIM(rv),1)) IN('1','Y','T') THEN
        SET rv='Y'
      ELSE
        SET rv='N'
      END IF
    END IF
  END IF;
  RETURN rv
END
}
  • database/procedures/pears_wpkmaintaingetswitchvalue.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1