Re: plpgsql FOR <select> LOOP question

From: Justin Banks <justinb(at)wamnet(dot)com>
To: Jan Wieck <wieck(at)debis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql FOR <select> LOOP question
Date: 2000-04-26 14:28:17
Message-ID: 14598.64235.855414.366754@flotsam.cops.wamnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


<courtesy copy emailed to wieck(at)debis(dot)com>

>>>>> "Jan" == Jan Wieck <wieck(at)debis(dot)com> writes:

>> Hello - After reading the documentation several times, and
>> looking at the archives, I'm very confused. The PL/pgSQL
>> documentation states that :

Jan> Looks like you're confused.

Yup, I was.

>> FOR lgid IN select gid from groups_acl where login = NEW.login LOOP
>> ...<do stuff with lgid>...

Jan> Here you have the syntax right, but I assume "lgid" isn't
Jan> a record or row type variable.

Actually, it wasn't, that's where I was confused. I had thought that
since I knew the datatype I was selecting, declaring a variable of
that type was sufficient. Apparently it's not ;)

Jan> This time you messed up the syntax. Write it as

Jan> FOR rec IN select * from groups_acl where login =
Jan> NEW.login LOOP ... END LOOP;

What I wanted was to be pedantic about the datatype I was selecting
(for no particular reason, I guess), but now I understand that I've
got to have something of the general type record.

Of course, as always happens, right after I mailed to the list, I
figured it out myself.

Thanks.

-justinb

--
Justin Banks - WAM!NET Inc., Eagan MN justinb(at)wamnet(dot)com
I'd fix it for you, but I don't want to break into your site.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2000-04-26 14:41:39 Re: pgsql DATE
Previous Message Peter Eisentraut 2000-04-26 13:53:34 RE: unique row identifier data type exhausted . . .