From: | Jaime Casanova <systemguards(at)yahoo(dot)com> |
---|---|
To: | Eric Aponte <eaponte(at)usb(dot)ve>, pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Columnas afectadas en Postgresql |
Date: | 2004-07-20 17:28:07 |
Message-ID: | 20040720172807.78608.qmail@web50001.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hi Eric, antes que nada te recuerdo que todos los mails debes enviarlos al foro de todas formas voy a leerlo:
Eric Aponte <eaponte(at)usb(dot)ve> wrote:
Muchas gracias por el dato,pero no he logrado hacerlo funcionar, te mando el codigo:
CREATE OR REPLACE FUNCTION query (varchar) RETURNS numeric AS'
declare
var_sw numeric;
registros numeric;
begin
execute $1;
get diagnostics registros = row_count;
if registros = 1 then
var_sw = 1
-- var_sw = 1; debe terminar en punto y coma
-- ademas toda asignacion se hace con := y no solo con =
-- con eso funciona
else
var_sw = 0;
end if;
return var_sw;
end;
'LANGUAGE 'plpgsql';
Jaime Casanova escribió:
El comando que te interesa es:GET DIAGNOSTICS integer_var = ROW_COUNT;Tomado del manual de postgres:37.6.5. Obtaining the Result StatusThere are several ways to determine the effect of acommand. The first method is to use the GETDIAGNOSTICS command, which has the form: GET DIAGNOSTICS variable = item [ , ... ] ;This command allows retrieval of system statusindicators. Each item is a key word identifying astate value to be assigned to the specified variable(which should be of the right data type to receiveit). The currently available status items areROW_COUNT, the number of rows processed by the lastSQL command sent down to the SQL engine, andRESULT_OID, the OID of the last row inserted by themost recent SQL command. Note that RESULT_OID is onlyuseful after an INSERT command. An example: GET DIAGNOSTICS integer_var = ROW_COUNT;The second method to determine the effects of acommand is to check the special variable named FOUND,which is of type boolean. FOUND starts out falsewith
in each
PL/pgSQL function call. It is set by eachof the following types of statements: A SELECT INTO statement sets FOUND true if it returnsa 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 trueif at least one row is affected, false if no row isaffected. A FETCH statement sets FOUND true if it returns a row,false if no row is returned. Atentamente, Jaime CasanovaAlvaro Herrera Munoz <alvherre(at)dcc(dot)uchile(dot)cl> wrote:OnMon, Jul 19, 2004 at 12:33:08PM -0400, Eric Apontewrote:
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 GETDIAGNOSTICS o algo asi.
Atentamente,
Jaime Casanova
---------------------------------
Do You Yahoo!?
Todo lo que quieres saber de Estados Unidos, América Latina y el resto del Mundo.
Visíta Yahoo! Noticias.
From | Date | Subject | |
---|---|---|---|
Next Message | Eric Aponte | 2004-07-20 19:09:05 | Re: Columnas afectadas en Postgresql |
Previous Message | Mauricio Cisneros Aguilar | 2004-07-20 16:05:14 | Ayuda Urgente |