[Pgsql-ayuda] RV: function syb/pgsql

sandrigo lezcano psql@msa.com.py
Mon, 2 Jun 2003 14:00:00 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C3290F.4243E560
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


un modelito por favor...
si este es mi funcion en Sybase=20
obs: T_GUARANIES tendria q definirlo como numeric(13,2)

--- sybase function -----------------------------------------
alter function=20
   sal.f_aporte_ips(in @lugar smallint,in @anio integer,in @mes integer)
   returns T_GUARANIES=20

begin=20
  declare @ips T_GUARANIES;
  select sum(round(novedades_proceso_historico.base=20
        * novedades_proceso_historico.cantidad=20
        * novedades_proceso_historico.factor,0))
  into @ips from novedades_proceso_historico,cargos_unidades
 where (novedades_proceso_historico.legajo         =3D =
cargos_unidades.legajo)
   and (cargos_unidades.lugar_de_trabajo           =3D @lugar)=20
   and (novedades_proceso_historico.anio           =3D @anio)  =20
   and (novedades_proceso_historico.mes            =3D @mes)=20
   and (novedades_proceso_historico.planilla       =3D '1')
   and (novedades_proceso_historico.numero_proceso =3D 9)
   and (novedades_proceso_historico.novedad        =3D 50)=20
   and (month(cargos_unidades.fecha_egreso)        =3D @mes);

 return @ips=20
end

---- en PostgreSQL  ---------------------------
create function f_aporte_ips(lugar int2, anio integer, mes integer)
   returns numeric(13,2) AS '
   declare=20
     ips numeric(13,2);
   begin
      select sum(round(novedades_proceso_historico.base =20
                    * novedades_proceso_historico.cantidad=20
                    * novedades_proceso_historico.factor,0))
      into ips from novedades_proceso_historico,cargos_unidades
     where (novedades_proceso_historico.legajo         =3D =
cargos_unidades.legajo)
       and (cargos_unidades.lugar_de_trabajo           =3D lugar)=20
       and (novedades_proceso_historico.anio           =3D anio)  =20
       and (novedades_proceso_historico.mes            =3D mes)=20
       and (novedades_proceso_historico.planilla       =3D '1')
       and (novedades_proceso_historico.numero_proceso =3D 9)
       and (novedades_proceso_historico.novedad        =3D 50)=20
       and (month(cargos_unidades.fecha_egreso)        =3D mes);
       end;
   ' language 'sql';

-------------------------



____________________________________________________
Sandrigo Lezcano Jara             Asunci=F3n, Paraguay
usando______: Ret Hat 7.2 (Enigma) - Kernel 2.4.7-10=20
              PostgreSQL 7.1.3 - psqlODBC 7.02.00.01
migrando____: Sybase 6.5   al   PostgreSQL=20
front end___: PowerBuilder 6.5        =20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DICQ:143590717=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
____________________________________________________

------=_NextPart_000_002D_01C3290F.4243E560
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp;</DIV>
<DIV>un modelito por favor...</DIV>
<DIV>si este es mi funcion en Sybase </DIV>
<DIV>obs: T_GUARANIES tendria q definirlo como numeric(13,2)</DIV>
<DIV>&nbsp;</DIV>
<DIV>--- sybase function -----------------------------------------</DIV>
<DIV>alter function <BR>&nbsp;&nbsp; sal.f_aporte_ips(in @lugar =
smallint,in=20
@anio integer,in @mes integer)<BR>&nbsp;&nbsp; returns T_GUARANIES =
</DIV>
<DIV>&nbsp;</DIV>
<DIV>begin <BR>&nbsp; declare @ips T_GUARANIES;<BR>&nbsp; select=20
sum(round(novedades_proceso_historico.base&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *=20
novedades_proceso_historico.cantidad=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *=20
novedades_proceso_historico.factor,0))<BR>&nbsp; into @ips from=20
novedades_proceso_historico,cargos_unidades<BR>&nbsp;where=20
(novedades_proceso_historico.legajo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
=3D cargos_unidades.legajo)<BR>&nbsp;&nbsp; and=20
(cargos_unidades.lugar_de_trabajo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=3D @lugar) <BR>&nbsp;&nbsp; and=20
(novedades_proceso_historico.anio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=3D @anio)&nbsp;&nbsp; <BR>&nbsp;&nbsp; and=20
(novedades_proceso_historico.mes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D @mes) <BR>&nbsp;&nbsp; and=20
(novedades_proceso_historico.planilla&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 =3D=20
'1')<BR>&nbsp;&nbsp; and (novedades_proceso_historico.numero_proceso =3D =

9)<BR>&nbsp;&nbsp; and=20
(novedades_proceso_historico.novedad&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; =3D=20
50) <BR>&nbsp;&nbsp; and=20
(month(cargos_unidades.fecha_egreso)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; =3D=20
@mes);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;return @ips <BR>end</DIV>
<DIV>&nbsp;</DIV>
<DIV>---- en PostgreSQL&nbsp; ---------------------------</DIV>
<DIV>create function f_aporte_ips(lugar int2, anio integer, mes=20
integer)<BR>&nbsp;&nbsp; returns&nbsp;numeric(13,2) AS '</DIV>
<DIV>&nbsp;&nbsp; declare </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp; ips=20
numeric(13,2);<BR>&nbsp;&nbsp;&nbsp;begin</DIV>
<DIV>&nbsp;&nbsp;&nbsp; &nbsp; select=20
sum(round(novedades_proceso_historico.base&nbsp;=20
<DIV>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *=20
novedades_proceso_historico.cantidad=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *=20
novedades_proceso_historico.factor,0))<BR>&nbsp;&nbsp;&nbsp; &nbsp; into =
ips=20
from novedades_proceso_historico,cargos_unidades<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;where=20
(novedades_proceso_historico.legajo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
=3D cargos_unidades.legajo)<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(cargos_unidades.lugar_de_trabajo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=3D lugar) <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(novedades_proceso_historico.anio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;=20
=3D anio)&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(novedades_proceso_historico.mes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
=3D mes) <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(novedades_proceso_historico.planilla&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 =3D=20
'1')<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(novedades_proceso_historico.numero_proceso =3D 9)<BR>&nbsp;&nbsp;&nbsp; =

&nbsp;&nbsp; and=20
(novedades_proceso_historico.novedad&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; =3D=20
50) <BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; and=20
(month(cargos_unidades.fecha_egreso)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; =3D=20
mes);</DIV></DIV>
<DIV>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; end;</DIV>
<DIV>&nbsp;&nbsp; ' language&nbsp;'sql';</DIV>
<DIV>&nbsp;</DIV>
<DIV>-------------------------</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>____________________________________________________<BR>Sandrigo =
Lezcano=20
Jara&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
Asunci=F3n, Paraguay<BR>usando______: Ret Hat 7.2 (Enigma) - Kernel =
2.4.7-10=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
PostgreSQL 7.1.3 - psqlODBC 7.02.00.01<BR>migrando____: Sybase =
6.5&nbsp;&nbsp;=20
al&nbsp;&nbsp; PostgreSQL <BR>front end___: PowerBuilder=20
6.5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DICQ:143590717=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR>_________=
___________________________________________</DIV></BODY></HTML>

------=_NextPart_000_002D_01C3290F.4243E560--