Colocando order by ficou pior ainda, porque ele vai ordenar primeiro depois
vai fazer limit.


José Mello Júnior wrote:
> 
> Faltando o ORDER BY, pelo menos na sua mensagem.
> 
> []´s
> 
> 2009/1/7 mateusgra <[email protected]>
> 
>>
>> Na verdade ele traz so um registro so que demora muito parece que ela faz
>> o
>> limit no final.
>>
>> Se executar a consulta no psql ou na propria funcao ja com os valores dos
>> parametros preenchidos ele executa na hora.
>>
>>
>> Shairon Toledo wrote:
>> >
>> > Tenta depurar usando o raise notice, assim, depois da query
>> >
>> >  raise notice 'valor v1=%, v2=%,  resultado = ',v1,v2,resultado;
>> >
>> >
>> > On Wed, Jan 7, 2009 at 7:05 AM, mateusgra <[email protected]> wrote:
>> >
>> >>
>> >> Execute uma consulta simples dentro de uma plpgsql.
>> >>
>> >> So que o limit 1 não é executado ? Não deveria ser executado ?
>> >> Se eu colocar a consulta ja com os paramentros preenchidos o limit é
>> >> executado.
>> >>
>> >> CREATE FUNCTION TESTE(char,varchar)
>> >>  RETURNS varchar AS
>> >> $BODY$
>> >> DECLARE
>> >>   V1 ALIAS FOR $1;
>> >>   V2 ALIAS FOR $2;
>> >>   resultado varchar;
>> >> BEGIN
>> >>        SELECT nome INTO resultado FROM emp WHERE nome = v1 and bairro
>> =
>> >> v2
>> >> and
>> >> nome IS NOT NULL LIMIT 1;
>> >>
>> >>   IF FOUND THEN
>> >>     RETURN resultado;
>> >>   ELSE
>> >>     RETURN NULL;
>> >>   END IF;
>> >> END;
>> >> $BODY$
>> >>  LANGUAGE 'plpgsql' VOLATILE;
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/plpgsql-Limit1-tp21330021p21330021.html
>> >> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>> >>
>> >> _______________________________________________
>> >> pgbr-geral mailing list
>> >> [email protected]
>> >> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>> >>
>> >
>> >
>> >
>> > --
>> > [ ]'s
>> > Shairon Toledo
>> > http://www.hashcode.eti.br
>> >
>> > _______________________________________________
>> > pgbr-geral mailing list
>> > [email protected]
>> > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/plpgsql-Limit1-tp21330021p21330933.html
>>  Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> pgbr-geral mailing list
>> [email protected]
>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>
> 
> 
> 
> -- 
> José de Mello Júnior
> 41.9957-2007
> 
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/plpgsql-Limit1-tp21330021p21334075.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a