2011/5/4 Cesar Pedroso <[email protected]>

> Salve a todos,
>
> Estou com um probleminha aqui, preciso colocar uma function dentro de outro
> function isso é possivel.
>
> Segue exemplo porém deu erro.
>
> Obrigado pela ajuda
>
> At
> Cesat Moraes
>
> CREATE OR REPLACE FUNCTION teste()
>   RETURNS void AS
> $BODY$
>  BEGIN
>
>    SET search_path = xxx;
>    SET default_tablespace = xxx;
>
>    CREATE OR REPLACE FUNCTION FUNC1()
>      RETURNS void AS
>      $BODY$
>    DECLARE
>      vcount        numeric(1);
>    BEGIN
>
>    END;
>      $BODY$
>    LANGUAGE 'plpgsql';
> select * from FUNC1();
> drop function FUNC1();
>
>   RETURN;
> end; $BODY$
>   LANGUAGE 'plpgsql' VOLATILE;
>
>
>

Não sei para que vc precisa fazer isso, mas o indicado é utilizar o EXECUTE
[1] para criar a sua função dentro da outra.

...
EXECUTE $FUNC1$

   CREATE OR REPLACE FUNCTION FUNC1()
     RETURNS void AS
     $BODY$
   DECLARE
     vcount        numeric(1);
   BEGIN

   END;
     $BODY$
   LANGUAGE 'plpgsql';

$FUNC1$;
...

Ps: não testei o exemplo acima, mas deve funcionar corretamente.

[1]
http://www.postgresql.org/docs/9.0/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

-- 
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

Responder a