Re: for loop help

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: for loop help
Дата
Msg-id 20060405092449.GD15606@webserv.wug-glas.de
обсуждение исходный текст
Ответ на for loop help  ("Luis Silva" <lfs12@hotmail.com>)
Ответы transaction identifier
returning from a trigger
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: WAL to get back data in 7.4.
Следующее
От: Jan Danielsson
Дата:
Сообщение: Layout question