0
Opa gente, to trying to validate the cpfs of a query, are several Cpf"s. I have the following function to validate Cpf, but I’m not getting call-there
I’m trying to do it like this: SELECT CPF_VALIDACAO(NUMR_CPF) FROM PESSOAS
.
but it doesn’t work. Someone would know the right way to call this function?
CREATE OR REPLACE FUNCTION CPF_VALIDACAO
(p_cpf IN CHAR)
RETURN BOOLEAN
IS
m_total NUMBER := 0;
m_digito NUMBER := 0;
BEGIN
FOR i IN 1..9 LOOP
m_total := m_total + substr(p_cpf,i,1) * (11 - i);
END LOOP;
m_digito := 11 - mod(m_total,11);
IF m_digito > 9 THEN
m_digito := 0;
END IF;
IF m_digito != substr(p_cpf,10,1) THEN
RETURN FALSE;
END IF;
m_digito := 0;
m_total := 0;
FOR i IN 1..10 LOOP
m_total := m_total + substr(p_cpf,i,1) * (12 - i);
END LOOP;
m_digito := 11 - mod(m_total,11);
IF m_digito > 9 THEN
m_digito := 0;
END IF;
IF m_digito != substr(p_cpf,11,1) THEN
RETURN FALSE;
END IF;
RETURN TRUE;
end;
Which means "it doesn’t work"?
– anonimo
If possible change k the return of Function from Boolean to number (0 not valid , 1 valid), use Boolean in some frontends can give zebra.
– Motta