Re: duda/problema con query y funcion

From: Alvaro Herrera Roberto Rodríguez Pino "pgsql-es-ayuda(at)postgresql(dot)org" Re: duda/problema con query y funcion 2008-09-23 22:22:37 20080923222237.GD8885@alvh.no-ip.org (view raw or whole thread) 2008-09-22 22:19:31 from Roberto Rodríguez Pino  2008-09-23 19:28:25 from Roberto Rodríguez Pino   2008-09-23 20:01:41 from "Miguel Beltran R(dot)"    2008-09-23 20:19:54 from Roberto Rodríguez Pino    2008-09-23 22:17:47 from Roberto Rodríguez Pino     2008-09-25 17:05:53 from "Miguel Beltran R(dot)"  2008-09-23 22:05:38 from "Jaime Casanova"   2008-09-23 22:18:26 from Roberto Rodríguez Pino    2008-09-23 22:44:46 from Jenaro Centeno Gómez  2008-09-23 22:22:37 from Alvaro Herrera   2008-09-23 22:26:31 from Roberto Rodríguez Pino 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/)

```

pgsql-es-ayuda by date

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