Ele utilizou o nome de umas variáveis muito doidas! Parece Assembly
![Very Happy :-D](./images/smilies/icon_biggrin.gif)
CREATE OR REPLACE FUNCTION nome_funcao1 (P_CREATION_DATE IN DATE, P_LAST_UPDATE_DATE IN DATE, P_SABADO IN VARCHAR, P_ORIGEM IN NUMBER)RETURN NUMBER IS
V_HORA NUMBER(10) := 0;
V_CREATION_DATE NUMBER(10) := 0;
V_LAST_UPDATE_DATE NUMBER(10) := 0;
V_CONT DATE;
V_X DATE;
V_Y DATE;
V_CX NUMBER(5) := 0;
V_CY NUMBER(5) := 0;
V_CCONT NUMBER(5) := 0;
BEGIN
V_X := P_CREATION_DATE;
V_Y := P_LAST_UPDATE_DATE;
V_CX := nome_funcao2(TRUNC(V_X), P_ORIGEM);
V_CY := nome_funcao2(TRUNC(V_Y), P_ORIGEM);
IF (TRUNC(V_X) = TRUNC(V_Y) AND V_CX >= 100) AND ((TO_NUMBER(TO_CHAR(V_X,'D')) NOT IN (1,7) AND P_SABADO = 'N') OR P_SABADO = 'S') THEN
V_LAST_UPDATE_DATE := 0;
ELSE
IF (V_CX >= 100) AND ((TO_NUMBER(TO_CHAR(V_X,'D')) NOT IN (1,7) AND P_SABADO = 'N') OR P_SABADO = 'S') THEN
V_CREATION_DATE := 0;
END IF;
IF (V_CY >= 100) AND ((TO_NUMBER(TO_CHAR(V_Y,'D')) NOT IN (1,7) AND P_SABADO = 'N') OR P_SABADO = 'S') THEN
V_LAST_UPDATE_DATE :=(V_CREATION_DATE + 1);
ELSE
V_LAST_UPDATE_DATE := V_CREATION_DATE;
END IF;
END IF;
V_CONT := TRUNC(V_X);
LOOP
V_CONT := V_CONT + 1;
EXIT WHEN V_CONT >= TRUNC(V_Y);
V_CCONT := nome_funcao2(TRUNC(V_CONT), P_ORIGEM);
IF V_CCONT >= 100 AND P_SABADO = 'S' THEN
V_HORA := V_HORA + 1;
ELSIF ((TO_NUMBER(TO_CHAR(V_CONT,'D')) NOT IN (1,7) AND P_SABADO = 'N') AND V_CCONT>= 100) THEN
V_HORA := V_HORA + 1;
END IF;
END LOOP;
V_HORA := V_HORA + V_LAST_UPDATE_DATE;
RETURN V_HORA;
EXCEPTION
WHEN OTHERS THEN
RETURN 0;
END;