From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: for loop help |
Date: | 2006-04-05 09:24:49 |
Message-ID: | 20060405092449.GD15606@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 ===
From | Date | Subject | |
---|---|---|---|
Next Message | Winson Yung | 2006-04-05 21:22:18 | how to encrypt trigger function |
Previous Message | James Long | 2006-04-05 07:37:48 | How to append records into a file which has serial unique IDs? |