Skip site navigation (1) Skip section navigation (2)

Re: duda/problema con query y funcion

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Roberto Rodríguez Pino <rodpin(at)gmail(dot)com>
Cc: "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: duda/problema con query y funcion
Date: 2008-09-23 22:22:37
Message-ID: 20080923222237.GD8885@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
Roberto Rodríguez Pino escribió:

> CREATE OR REPLACE FUNCTION buscandoError(fecha date)
>   RETURNS void AS
> $BODY$
> DECLARE
> 	inv_temp record;
> BEGIN
> DELETE FROM inventariototal;
> FOR inv_temp IN
> 	(SELECT articulo.idarticulo, costoultimo.costoultimo
> 	FROM articulo
> 	LEFT OUTER JOIN costo USING (idarticulo)
> 	LEFT OUTER JOIN (select costo.idarticulo, costoultimo from
> costo,(select max(idcosto) as idcosto,idarticulo,max (fecha) from costo
> where fecha<=$1 group by idarticulo) as fechacosto where
> fechacosto.idcosto = costo.idcosto) as costoultimo USING (idarticulo)

El problema es que "fecha" es el nombre de una columna y además el
nombre del parámetro de la función.  Cámbiale el nombre a este último
para evitar el conflicto.





-- 
Alvaro Herrera                          Developer, http://www.PostgreSQL.org/
"How strange it is to find the words "Perl" and "saner" in such close
proximity, with no apparent sense of irony. I doubt that Larry himself
could have managed it."         (ncm, http://lwn.net/Articles/174769/)

In response to

Responses

pgsql-es-ayuda by date

Next:From: Roberto Rodríguez PinoDate: 2008-09-23 22:26:31
Subject: Re: duda/problema con query y funcion
Previous:From: Roberto Rodríguez PinoDate: 2008-09-23 22:18:26
Subject: Re: duda/problema con query y funcion

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group