Re: get diagnostics row_count y cursores

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Juan Pablo Yañez <jyanez(at)sigma(dot)gov(dot)bo>
Cc: pgsql-es-ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: get diagnostics row_count y cursores
Date: 2005-10-27 13:15:42
Message-ID: 20051027131541.GB531@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Juan Pablo Yañez escribió:
> Hola señores, tengo la siguiente funcion:
>
> CREATE OR REPLACE FUNCTION test() RETURNS integer AS
> $body$
> declare
> vl integer;
> vlvalor varchar;
> begin
> select columnaX into vlvalor from tablaX;
> if not found then
> raise notice 'no hay datos';
> else
> get diagnostics vl := row_count;
> raise notice 'deberia mostrar el numero de filas devueltas: %',vl;
> end if;
> return vl;
> end;
> $body$
> LANGUAGE 'plpgsql';
>
> Lo que espero que me devuelva la funcion es el numero de filas
> recuperado por el select pero siempre devuelve 1. Que es lo que estoy
> haciendo mal ?

El SELECT INTO puede recibir solamente una tupla. Prueba cambiando esa
linea por

perform columnaX from tablaX;

--
Alvaro Herrera http://www.PlanetPostgreSQL.org
"If you have nothing to say, maybe you need just the right tool to help you
not say it." (New York Times, about Microsoft PowerPoint)

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Luis Guevara 2005-10-27 13:19:32 Re: vistas
Previous Message Mauricio Arrano 2005-10-27 12:31:36 RE: vistas