SET TERM ^ ; CREATE OR ALTER PROCEDURE TEST ( UNIT INTEGER) RETURNS ( RESULT DATE) AS DECLARE VARIABLE START_DATE DATE; DECLARE VARIABLE START_VALIDITY INTEGER; DECLARE VARIABLE END_VALIDITY INTEGER; BEGIN START_DATE = '01/01/2021'; START_VALIDITY = 5; END_VALIDITY = 10; RESULT = CASE WHEN UNIT = 4 -- Day THEN DATEADD((END_VALIDITY - START_VALIDITY + 1) DAY TO START_DATE) WHEN UNIT = 5 -- Week THEN DATEADD((END_VALIDITY - START_VALIDITY + 1) WEEK TO START_DATE) WHEN UNIT = 7 -- Month THEN DATEADD((END_VALIDITY - START_VALIDITY + 1) MONTH TO START_DATE) END; SUSPEND; END^ SET TERM ; ^ /* Existing privileges on this procedure */ GRANT EXECUTE ON PROCEDURE TEST TO SYSDBA;