From: | Eric Aponte <eaponte(at)usb(dot)ve> |
---|---|
To: | Jaime Casanova <systemguards(at)yahoo(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Columnas afectadas en Postgresql |
Date: | 2004-07-22 14:03:33 |
Message-ID: | 40FFC935.2020500@usb.ve |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Eso es lo que espero, pero yo le estoy mandando un select ya que
necesito saber si el registro existe en la base de datos, si existe hago
una operacion y sino hago otra, voy a seguir intentando, muchas gracias
Jaime Casanova escribió:
> Hi Eric,
>
> Tengo esto hecho:
>
> CREATE TABLE tmp_prueba (
> col1 integer
> );
>
> insert into tmp_prueba values (1);
> insert into tmp_prueba values (2);
> insert into tmp_prueba values (3);
> insert into tmp_prueba values (4);
> insert into tmp_prueba values (5);
>
> CREATE OR REPLACE FUNCTION tmp_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;
> else
> var_sw := 0;
> end if;
> return var_sw;
> end;
> 'LANGUAGE 'plpgsql';
>
> select tmp_query('update tmp_prueba set col1 = col1 + 1 where col1 > 3');
> Cuando lo ejecuto: la funcion me devuelve cero porque se afectaron
> varias filas (2)
>
> Y si hago
> select tmp_query('update tmp_prueba set col1 = col1 + 1 where col1 < 2');
> la funcion me devuelve 1 porque se afecta 1 sola fila, eso es lo que
> la funcion dice que hace.
>
> Ese es el comportamiento correcto o esperabas otra cosa?
>
> Atentamente,
> Jaime Casanova
>
>
> Eric Aponte <eaponte(at)usb(dot)ve> wrote:
>
> Hice los cambios, pero no le asigna valor a la variable registros
>
> CREATE OR REPLACE FUNCTION query (text) RETURNS numeric AS'
>
> declare
> var_sw numeric;
> registros integer;
> begin
> execute $1;
> get diagnostics registros = row_count;
> if registros > 0 then
> var_sw := 1;
> else
> var_sw := 0;
> end if;
> return var_sw;
> end;
> 'LANGUAGE 'plpgsql';
>
> Gracias
>
>
> ------------------------------------------------------------------------
> Do You Yahoo!?
> <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com>
> Todo lo que quieres saber de Estados Unidos, América Latina y el resto
> del Mundo.
> Visíta Yahoo! Noticias
> <http://espanol.yahoo.com/mail_tagline/*http://espanol.news.yahoo.com>.
From | Date | Subject | |
---|---|---|---|
Next Message | Edwin Quijada | 2004-07-22 14:47:10 | Re: VB y PostgreSQL |
Previous Message | Mario Soto | 2004-07-21 22:39:31 | Re: hola tengo el siguiente error |