Re: Se puede hacer?

From: "Calabaza Calabaza" <calalinux(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Se puede hacer?
Date: 2008-03-18 15:42:52
Message-ID: 958993320803180842v34495b74vb0d5fc3c7c34260e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

2008/3/18, Jaime Sierra Gattorno <jhsgattorno(at)gmail(dot)com>:
> Soy nuevo en postgres y necesito saber si esto que funciona en MSSQL, se
> puede hacer en Postgres

> DECLARE @dFecha DateTime
>
> SET @dFecha = '17/03/2008'
>
> SELECT Sum(Total_Factura) WHERE Fecha_Factura = @dFecha

Sí se puede hacer;

date una vuelta por:
http://www.postgresql.org/docs/8.3/interactive/plpgsql.html

Imagino que tu código está recortado, entonces, aquí pongo una función
que hace más o menos, lo que quieres a ver si nos entendemos...

CREATE OR REPLACE FUNCTION tu_funcion()
RETURNS numeric AS
'
DECLARE
dFecha date;
resultado numeric;
BEGIN
dFecha := ''20080317'';
SELECT Sum(Total_Factura) WHERE Fecha_Factura = dFecha into resultado;
-- SELECT (5+3)::numeric into resultado;
return resultado;
END;
' LANGUAGE 'plpgsql' VOLATILE;

Y para probar haces:

Select tu_funcion()
***********************************************************
Obs:
Yo probé con el 5+3 y funciono bien, imagino que debería de andar con
tu select si posees (que tabla?, quizás facturas? falta el FROm de tu
select!!!!!!!)

Ahora lo que te escribí fue un ejemplo para la rama 7.4 de PgSQL.
Si tienes otra rama, mira el manual a ver si varía mucho.

Espero haberte ayudado.

Fuerza!
--
§~^Calabaza^~§ from Villa Elisa, Paraguay
----------------
A hendu hína: Primal Fear - The Inmortal Ones
http://foxytunes.com/artist/primal+fear/track/the+inmortal+ones

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2008-03-18 15:44:35 Re: gran cantidad texto
Previous Message Jaime Sierra Gattorno 2008-03-18 15:37:38 Se puede hacer ?