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

* loop query results
@ 2002-12-04 08:58  Stefan Reuschke <reuschke_ukl@web.de>
  0 siblings, 1 reply; 2+ messages in thread

From: Stefan Reuschke @ 2002-12-04 08:58 UTC (permalink / raw)
  To: pgsql-sql


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




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

* Re: loop query results
@ 2002-12-04 09:21  Dennis Björklund <db@zigo.dhs.org>
  parent: Stefan Reuschke <reuschke_ukl@web.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Dennis Björklund @ 2002-12-04 09:21 UTC (permalink / raw)
  To: Stefan Reuschke <reuschke_ukl@web.de>; +Cc: pgsql-sql

On Wed, 4 Dec 2002, Stefan Reuschke wrote:

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

I tried you exact example in 7.2.1 and got every row only once. It doesn't
help you find the error perhaps, but it doesn't hurt to know that it works
as intended here.

-- 
/Dennis




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


end of thread, other threads:[~2002-12-04 09:21 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-12-04 08:58 loop query results Stefan Reuschke <reuschke_ukl@web.de>
2002-12-04 09:21 ` Dennis Björklund <db@zigo.dhs.org>

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