Desculpa estava esquecendo de uma linha... Agora está OK
-- Function: fproxdiautil(date) -- DROP FUNCTION fproxdiautil(date); CREATE OR REPLACE FUNCTION fdiasuteis(pData date, pDias integer) RETURNS date AS $BODY$ declare Dia integer; SomaDias integer; NovaData date; Begin SomaDias = 0; NovaData = pData; while (SomaDias < pDias) loop NovaData = NovaData + 1; Dia = extract(dow from NovaData); while (Dia = 0 or Dia = 6) loop NovaData = NovaData + 1; Dia = extract(dow from NovaData); end loop; SomaDias = SomaDias + 1; end loop; return fproxdiautil(NovaData); end; $BODY$ LANGUAGE plpgsql VOLATILE COST 100; ALTER FUNCTION fdiasuteis(date, integer) OWNER TO postgres; Marcelo Silva
_______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral