pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Looping recordset
2+ messages / 2 participants
[nested] [flat]

* Looping recordset
@ 2007-01-25 19:45  Furesz Peter <spam@srv.hu>
  0 siblings, 1 reply; 2+ messages in thread

From: Furesz Peter @ 2007-01-25 19:45 UTC (permalink / raw)
  To: pgsql-sql

Hello,

How can I loop a PL/PgSQL recorset variable? The example:

    DECLARE
        v_tmp_regi RECORD;
        v_tmp RECORD;
    BEGIN
      SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE 
sf.termekfajta_id=
      a_termekfajta_id AND sf.marka_id=a_marka_id;

        DELETE FROM sulyozas_futamido;

        FOR v_tmp IN v_tmp_regi LOOP
            --I would like to work here with the old recordset!
        END LOOP;
        ^^^^^^^^^^^^^^
       -- This is not working !!!

    END;




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Looping recordset
@ 2007-01-26 00:56  Hélder M. Vieira <hmv@mail.telepac.pt>
  parent: Furesz Peter <spam@srv.hu>
  0 siblings, 0 replies; 2+ messages in thread

From: Hélder M. Vieira @ 2007-01-26 00:56 UTC (permalink / raw)
  To: pgsql-sql


>    DECLARE
>        v_tmp_regi RECORD;
>        v_tmp RECORD;
>    BEGIN
>      SELECT * INTO v_tmp_regi FROM sulyozas_futamido sf WHERE 
> sf.termekfajta_id=
>      a_termekfajta_id AND sf.marka_id=a_marka_id;
>
>        DELETE FROM sulyozas_futamido;
>
>        FOR v_tmp IN v_tmp_regi LOOP
>            --I would like to work here with the old recordset!
>        END LOOP;
>        ^^^^^^^^^^^^^^
>       -- This is not working !!!


I'd say v_tmp_regi is a record variable, it is supposed to hold one record, 
not a set of records.
Depending on the purpose, I'd probably use a temporary table to hold the 
selected rows or, perhaps, use the SELECT in the FOR..LOOP and subsequently 
perform the DELETE.


Hélder M. Vieira 




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-01-26 00:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-01-25 19:45 Looping recordset Furesz Peter <spam@srv.hu>
2007-01-26 00:56 ` Hélder M. Vieira <hmv@mail.telepac.pt>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox