Re: for loop help - Mailing list pgsql-novice

From A. Kretschmer
Subject Re: for loop help
Date
Msg-id 20060405092449.GD15606@webserv.wug-glas.de
Whole thread Raw
In response to for loop help  ("Luis Silva" <lfs12@hotmail.com>)
Responses transaction identifier  ("Luis Silva" <lfs12@hotmail.com>)
returning from a trigger  ("Luis Silva" <lfs12@hotmail.com>)
List pgsql-novice
am  05.04.2006, um  0:01:02 +0100 mailte Luis Silva folgendes:
> Hi! Is it possible to know in a loop in pl/pgsql if the next element is de
> last? exemple
>
> DECLARE
> asds Record;
>
> BEGIN
>
> FOR  asds IN EXECUTE 'select id from user_table' LOOP
>
>     IF asds.id.next = last THEN
>                 ......
>     END IF;
>
> END LOOP;

You can use a cursor and walk with the cursor through the result.
(move last cursor_name -> you have the last id, then move first, then
your for ... loop and check the id if is it the last id)


Perhaps, there are better solutions...


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: WAL to get back data in 7.4.
Next
From: Jan Danielsson
Date:
Subject: Layout question