Jorge Vilela escreveu:
> Pessoal, há poucos dias postei uma duvida sobre como usar o nome do 
> argumento da função como variável sem o uso de ALIAS FOR.
> 
> Testei aqui mas não tive êxito
> 
> Um exemplo de função:
> 
> CREATE OR REPLACE FUNCTION "public"."testearg" ("Pusu_id" integer, 
> "Pacao" varchar, "Ptip_doc_id" integer) RETURNS "public"."tipo_mensagem" AS
> $body$
> DECLARE
>        Flemb_id             INTEGER;
>        saida                public.tipo_mensagem;
>        logar                BOOLEAN;
> BEGIN
>      IF(Pacao='INSERIR')THEN
>         RETURN saida;
>      END IF;
> END;
> $body$
> LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
> 
> Se rodo ela retorna o seguinte erro:
> 
> ERROR:  coluna "pacao" não existe
                   ^^^^^

> CONTEXT:  comando SQL "SELECT (Pacao='INSERIR')"
> PL/pgSQL function "testearg" line 6 at if
> 
> 
> ------------------------------------------------------------------------


Desculpe, me passou despercebido!

Como você declarou entre aspas precisa utilizar sempre entre aspas 
("Pacao").

Veja:
http://www.postgresql.org/docs/8.1/interactive/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS

"Quoting an identifier also makes it case-sensitive, whereas unquoted 
names are always folded to lower case. For example, the identifiers FOO, 
foo, and "foo" are considered the same by PostgreSQL, but "Foo" and 
"FOO" are different from these three and each other. (The folding of 
unquoted names to lower case in PostgreSQL is incompatible with the SQL 
standard, which says that unquoted names should be folded to upper case. 
Thus, foo should be equivalent to "FOO" not "foo" according to the 
standard. If you want to write portable applications you are advised to 
always quote a particular name or never quote it.)"

[]s
Osvaldo

                
_______________________________________________________ 
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. 
Registre seu aparelho agora! 
http://br.mobile.yahoo.com/mailalertas/ 
 

_______________________________________________
Grupo de Usuários do PostgreSQL no Brasil
Antes de perguntar consulte o manual
http://pgdocptbr.sourceforge.net/

Para editar suas opções ou sair da lista acesse a página da lista em:
http://pgfoundry.org/mailman/listinfo/brasil-usuarios

Responder a