CREATE OR REPLACE FUNCTION FORMATMASK (P_IDTIPOINS IN VARCHAR2,
									            P_INSCRICAO IN VARCHAR2) RETURN VARCHAR2 IS

   V_FORMATMASK VARCHAR2(50);
BEGIN
   SELECT CASE P_IDTIPOINS
            WHEN 'F' THEN (SUBSTR(P_INSCRICAO,0,3)||'.'||
                           SUBSTR(P_INSCRICAO,4,3)||'.'||
                           SUBSTR(P_INSCRICAO,7,3)||'-'||
                           SUBSTR(P_INSCRICAO,10,2))
            WHEN 'J' THEN (SUBSTR(P_INSCRICAO,0,2)||'.'||
                           SUBSTR(P_INSCRICAO,3,3)||'.'||
                           SUBSTR(P_INSCRICAO,6,3)||'/'||
                           SUBSTR(P_INSCRICAO,9,4)||'-'||
                           SUBSTR(P_INSCRICAO,13))
            ELSE  P_INSCRICAO END
     INTO V_FORMATMASK
     FROM DUAL;

   RETURN(V_FORMATMASK);
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('FORMATMASK','6.35.009'); END;
/
