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

Re: Stored procedures and "pseudo" fields..

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: Lars Erik Thorsplass <thorsplass(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Stored procedures and "pseudo" fields..
Date: 2004-07-20 13:57:37
Message-ID: 40FD24D1.1090005@klaster.net (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
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;

Regards,
Tomasz Myrta


In response to

Responses

pgsql-sql by date

Next:From: Markus BertheauDate: 2004-07-20 14:11:16
Subject: Re: Stored procedures and "pseudo" fields..
Previous:From: Lars Erik ThorsplassDate: 2004-07-20 13:34:20
Subject: Stored procedures and "pseudo" fields..

pgsql-general by date

Next:From: Markus BertheauDate: 2004-07-20 14:11:16
Subject: Re: Stored procedures and "pseudo" fields..
Previous:From: Lars Erik ThorsplassDate: 2004-07-20 13:34:20
Subject: Stored procedures and "pseudo" fields..

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