pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stefan Reuschke <reuschke_ukl@web.de>
To: pgsql-sql@postgresql.org
Subject: loop query results
Date: Wed, 4 Dec 2002 09:58:37 +0100
Message-ID: <200212040858.gB48wbX04370@mailgate5.cinetic.de> (raw)


With the following function I expected to get an iteration through the results. But the loop seems to be performed two times instead.

The function (postgres 7.2):

create function echt_char_laenge ()
  returns integer
  as

 '
declare
   char_auslese record;

   begin
    for char_auslese in select * from varlaenge loop
    raise notice ''%,   %'', char_auslese.id_var,  char_auslese.var_text;
   end loop;

return 0;
end;
 '
 language 'plpgsql';

------------------------------------------------------------

the result:

select echt_char_laenge ();

NOTICE:  1,   text 1X
NOTICE:  2,   text 2X
NOTICE:  3,   text 3X
NOTICE:  4,   text 4X
NOTICE:  5,   text 5X
NOTICE:  6,   text 6X
NOTICE:  1,   text 1X
NOTICE:  2,   text 2X
NOTICE:  3,   text 3X
NOTICE:  4,   text 4X
NOTICE:  5,   text 5X
NOTICE:  6,   text 6X
 echt_char_laenge
------------------
                0
(1 row)

----------

and the result as expected:

select * from varlaenge;

 id_var |  var_text
--------+-------------
      1 | text 1X
      2 | text 2X
      3 | text 3X
      4 | text 4X
      5 | text 5X
      6 | text 6X
(6 rows)


Any ideas?

Thanx
Stefan

______________________________________________________________________________
Schneller als andere! Die Blitz-SMS von WEB.DE FreeMail!
http://freemail.web.de/features/?mc=021167




view thread (2+ messages)  latest in thread

Message-ID: <200212040858.gB48wbX04370@mailgate5.cinetic.de>
Permalink:  ../200212040858.gB48wbX04370@mailgate5.cinetic.de/
Also on:    postgresql.org/message-id/200212040858.gB48wbX04370@mailgate5.cinetic.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: reuschke_ukl@web.de
  Subject: Re: loop query results
  In-Reply-To: <200212040858.gB48wbX04370@mailgate5.cinetic.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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