Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group