Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Loop plpgsql recordset


  • From: Alban Hertroys <alban(at)magproductions(dot)nl>
  • To: Furesz Peter <fureszpeter(at)srv(dot)hu>
  • Cc: postgres levlista <pgsql-general(at)postgresql(dot)org>
  • Subject: Re: Loop plpgsql recordset
  • Date: Mon, 29 Jan 2007 10:16:26 +0100
  • Message-id: <45BDBB6A(dot)6050000(at)magproductions(dot)nl>

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

How do you expect to loop one record?

In a recent thread (with a remarkably similar question - maybe you asked
this before?) it was suggested to move the SELECT statement to where the
RECORD type variable is. FOR .. IN .. expects a query.

Maybe a result set would work, but a RECORD type variable is *not* a
result set. Or a query, for that matter.

Fixing this is still not going to work for anything but the first result
though, as you delete the entire table constents right after it.

Maybe you should start by explaining what your function is supposed to do?

For lack of that, I think you meant this:

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

        -- Work here with the old recordset
      END LOOP;

      DELETE FROM sulyozas_futamido;
    END;

-- 
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group