Em 9 de dezembro de 2010 13:44, Marcelo Florindo <
[email protected]> escreveu:
> Colegas eu tenho uma função para validar usuário:
>
> declare
>
> v_codigo integer;
>
> begin
>
> select id_usuario into v_codigo
> from seguranca.usuario
> where id_usuario=codigo_usuario;
>
> return true;
>
> exception
> when no_data_found then
> return false;
>
> end;
>
>
O que me parece não estar certo é essa parte que vc inseriu um "exception",
de acordo com a documentação oficial [1] creio que deveria ser:
begin
begin
select id_usuario into v_codigo
from seguranca.usuario
where id_usuario=codigo_usuario;
return true;
exception
when no_data_found then
return false;
end;
end;
De qualquer forma poderia dar uma dica? Pq não fazer simplesmente:
begin
select id_usuario into v_codigo
from seguranca.usuario
where id_usuario=codigo_usuario;
if found then
return true;
end if;
return false;
end;
[1]
http://www.postgresql.org/docs/current/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
--
Fabrízio de Royes Mello
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral