Ages ago, when I was first learning the syntax and style of T-SQL, I was always trying to figure out when you would ever need to use the ACOS function. Afterall, a relational database didn't seem to be the most conducive place for doing things like trigonometry. But I guess I never thought that way John Watson's colleague did ...
FUNCTION BUS_RULE_FL (VCTRY_ID IN varchar2, VBUSU_ID IN varchar2, VEXTSYS_ID IN number, VBUS_RULE IN varchar2) RETURNS NUMBER AS -- return TRUE (1) or FALSE (0) whether the supplied business rule -- is selected for the supplied values of CTRY, LNG, EXTSYS VLOOPER NUMBER := 0; VCNT NUMBER := 0; BEGIN -- this loop will try all combinations of matching ctry/busu/extsys columns to either -- supplied values or null until a match is found, or all combinations exhausted WHILE VLOOPER < 8 AND VCNT = 0 LOOP SELECT COUNT(*) INTO VCNT FROM B2R_BUSINESS_FULE_USAGE WHERE BBUSRL_NM = VBUS_RULE AND NVL(BCTRY_ID, TO_CHAR(ACOS(-1))) = DECODE(MOD(FLOOR(VLOOPER /4), 2), 0, VCTRY_ID, TO_CHAR(ACOS(-1))) AND NVL(BBUSU_ID, TO_CHAR(ACOS(-1))) = DECODE(MOD(FLOOR(VLOOPER /2), 2), 0, VCTRY_ID, TO_CHAR(ACOS(-1))) AND NVL(BEXTSYS_ID, ACOS(-1)) = DECODE(MOD(VLOOPER, 2), 0, VEXTSYS_ID, ACOS(-1)); VLOOPER := VLOOPER + 1; END LOOP; RETURN VCNT; EXCEPTION WHEN OTHERS THEN RETURN 0; END;
Note that John typed this PL/SQL out from a paper copy. This particular function led to the banning all stored procedures, views, triggers and other database artifacts from the system architecture. You can only immagine how well things went from there.
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!