Certo, mas pode me dar um exemplo, de como ficaria isso?

Em 25 de abril de 2013 08:54, Jean Domingues <[email protected]>escreveu:

> Mas vc esta retornando um record onde deveria retornar numeric. E, se for
> set of, retorne com return next (varios registros), senao, nao use setof,
> use apenas numeric no tipo do retorno.
>
>   ------------------------------
>  *De:* izaque Maciel <[email protected]>
> *Para:* Comunidade PostgreSQL Brasileira <
> [email protected]>
> *Enviadas:* Quinta-feira, 25 de Abril de 2013 8:11
> *Assunto:* [pgbr-geral] Stored Procedure.
>
> Bom dia pessoal, não consegui concluir esta procedure pela questão do
> retorno, que tem que me retornar todos os campos do "último select" abaixo,
> e com o retorno deste último select, criarei outra stored procedure para
> pegar o retorno dessa e trabalharei alguns cálculos. Peço a ajuda de vocês,
> obrigado.
>
>
> CREATE OR REPLACE FUNCTION public.retorna_valores_go (
>   id_emolumento numeric(12,2),
>   dt_calculo_emol date,
>   valor_documento numeric(12,2)
> )
> RETURNS SETOF numeric AS
> $body$
> DECLARE
>
>   vidEmolumento numeric(12,2);
>   vidVigencia numeric(12,2);
>   vidEmolItens numeric(12,2);
>   regEmolItens record;
> BEGIN
>
>   -- Verifica se existe o emolumento
>   select e.id into vidEmolumento
>   from emolumentos e
>   where e.id = id_emolumento;
>
>   -- Se encontrado, localiza a vigência
>   if (videmolumento is not null) then
>   begin
>   select v.id into vidvigencia
>     from vigencia v
>     where dt_calculo_emol between v.dt_inicial and v.dt_final;
>
>     -- Se econtrada a vigência, localiza o emolumento pelo valor
>     if (vidvigencia is not null) then
>       select e.id into videmolitens
>       from emolumentos_itens e
>       where valor_documento between e.fx_valor_final and e.fx_valor_final;
>     end if;
>
>     -- Se foi localizado o emolumento
>     if (videmolitens is not null) then
>       select e.id into videmolitens
>       from emolumentos_itens e
>       where e.id_emolumentos  = videmolumento and
>             e.id_vigencia = vidvigencia and
>             e.fx_valor_inicial = 0 and
>             e.fx_valor_final   = 0;
>     end if;
>
>     if (videmolitens is not null) then
>     begin
>       select e.id,
>              e.id_emolumentos,
>              e.fx_valor_inicial,
>              e.fx_valor_final,
>              e.valor_emolumento,
>              e.tx_jud,
>              e.fundesp,
>              e.valor2,
>              e.valor3,
>              e.valor4,
>              e.valor5,
>              e.outras_despesas,
>              e.pag_extra_inicio,
>              e.valor_pag_extra,
>              e.fundo_pag_extra,
>              e.tx_jud_pag_extra,
>              e.cod_tab_correg,
>              e.cod_interno,
>              e.calc_txjud,
>              e.calc_fundesp,
>              e.calc_valor2,
>              e.calc_valor3,
>              e.calc_valor4,
>              e.calc_valor5,
>              e.calc_pagina_extra into regEmolItens
>   from emolumentos_itens e
>       where valor_documento between e.fx_valor_final and e.fx_valor_final;
>
>       return regEmolItens;
>     end;
>     end if;
>   end;
>   end if;
>
>
> END
> $body$
> LANGUAGE 'plpgsql'
> VOLATILE
> CALLED ON NULL INPUT
> SECURITY INVOKER
> COST 100;
>
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
>
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>
>
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a