From: Markus Bertheau <twanger@bluetwanger.de>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: Lars Erik Thorsplass <thorsplass@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Stored procedures and "pseudo" fields..
Date: Tue, 20 Jul 2004 16:11:16 +0200
Message-ID: <1090332676.3241.31.camel@dicaprio.akademie1.de> (raw)
In-Reply-To: <40FD24D1.1090005@klaster.net>
References: <7eeb33a040720034319e036c6@mail.gmail.com>
<7eeb33a04072006342b5d35a0@mail.gmail.com>
<40FD24D1.1090005@klaster.net>
В Втр, 20.07.2004, в 15:57, Tomasz Myrta пишет:
> On 2004-07-20 15:34, Użytkownik Lars Erik Thorsplass napisał:
> > My stored procedure "acl_check()" takes two integers as parameters.
> > Param1 is the object id to check acl on, Param 2 is the object id of
> > the user currently using the system. The procedure returns a positive
> > number (1 or 3 ) if you have some kind of access to the object. As one
> > might understand I want the returned value from the acl_check()
> > procedure to be a part of the result set.
> >
> > Kinda like this:
> >
> > SELECT *, acl_check( objects.obid, <user_id> ) AS mode FROM objects
> > WHERE mode > 0;
> >
> > This gives me a: ERROR: column "mode" does not exist
>
> You can't access column output alias in where clause. Instead you have
> to use your function twice:
>
> SELECT *, acl_check( objects.obid, <user_id> ) AS mode FROM objects
> WHERE acl_check( objects.obid, <user_id> ) > 0;
and if you properly marked the function STABLE and I am not mistaken,
then PostgreSQL is smart enough to execute the function only once per
row.
--
Markus Bertheau <twanger@bluetwanger.de>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: twanger@bluetwanger.de, jasiek@klaster.net, thorsplass@gmail.com
Subject: Re: Stored procedures and "pseudo" fields..
In-Reply-To: <1090332676.3241.31.camel@dicaprio.akademie1.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox