====== pears.GetMinWage ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."GetMinWage" IS {create function GetMinWage( in "persid" char(20),in @period integer ) returns double begin declare "rv" double; declare "myage" integer; set "rv" = 0; select "truncnum"("datediff"("day","dob","weekmonthenddate"(@period,'W'))/365.25,0) into "myage" from "person" where "personid" = "persid"; if "isnull"("GetQuestDate"('X','MDT','X'),"weekmonthenddate"(@period,'W')) > "weekmonthenddate"(@period,'W') then select(if "myage" < 18 then "GetQuestAnswer"('X','OIN','X') else if "myage" in( 18,19,20 ) then "GetQuestAnswer"('X','O18','X') else if "myage" in( 21,22 ) then "GetQuestAnswer"('X','O21','X') else "GetQuestAnswer"('X','O25','X') endif endif endif) into "rv" else select(if "myage" < 18 then "GetQuestAnswer"('X','MIN','X') else if "myage" in( 18,19,20 ) then "GetQuestAnswer"('X','M18','X') else if "myage" in( 21,22 ) then "GetQuestAnswer"('X','M21','X') else "GetQuestAnswer"('X','M25','X') endif endif endif) into "rv" end if; return "rv" end }