Re: Columnas afectadas en Postgresql

From: Jaime Casanova <systemguards(at)yahoo(dot)com>
To: Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl>, Eric Aponte <eaponte(at)usb(dot)ve>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Columnas afectadas en Postgresql
Date: 2004-07-19 22:15:43
Message-ID: 20040719221543.19969.qmail@web50007.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El comando que te interesa es:
GET DIAGNOSTICS integer_var = ROW_COUNT;

Tomado del manual de postgres:
37.6.5. Obtaining the Result Status
There are several ways to determine the effect of a
command. The first method is to use the GET
DIAGNOSTICS command, which has the form:

GET DIAGNOSTICS variable = item [ , ... ] ;

This command allows retrieval of system status
indicators. Each item is a key word identifying a
state value to be assigned to the specified variable
(which should be of the right data type to receive
it). The currently available status items are
ROW_COUNT, the number of rows processed by the last
SQL command sent down to the SQL engine, and
RESULT_OID, the OID of the last row inserted by the
most recent SQL command. Note that RESULT_OID is only
useful after an INSERT command.

An example:

GET DIAGNOSTICS integer_var = ROW_COUNT;

The second method to determine the effects of a
command is to check the special variable named FOUND,
which is of type boolean. FOUND starts out false
within each PL/pgSQL function call. It is set by each
of the following types of statements:

A SELECT INTO statement sets FOUND true if it returns
a row, false if no row is returned.


A PERFORM statement sets FOUND true if it produces
(and discards) a row, false if no row is produced.


UPDATE, INSERT, and DELETE statements set FOUND true
if at least one row is affected, false if no row is
affected.


A FETCH statement sets FOUND true if it returns a row,
false if no row is returned.

Atentamente,
Jaime Casanova

Alvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl> wrote:On
Mon, Jul 19, 2004 at 12:33:08PM -0400, Eric Aponte
wrote:
> Hola listeros, como estan, necesito ayuda con lo
siguiente, estoy ceando
> una funcion donde le mando a traves de un parametro
un query que deseo
> ejecutar, luego de ejecutarlo necesito saber cuantos
registros afecto:

Creo que puedes obtener esta informacion con GET
DIAGNOSTICS o algo asi.

--
Alvaro Herrera ()
La web junta la gente porque no importa que clase de
mutante sexual seas,
tienes millones de posibles parejas. Pon "buscar gente
que tengan sexo con
ciervos incendiánse", y el computador dirá
"especifique el tipo de ciervo"
(Jason Alexander)

---------------------------(end of
broadcast)---------------------------
TIP 8: explain analyze es tu amigo

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mauricio Cisneros Aguilar 2004-07-20 16:05:14 Ayuda Urgente
Previous Message Mario Soto 2004-07-19 22:09:35 Re: necesito ayuda con funciones