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

Re: CASE eval issue

From: Aaron Burt <aaron(at)bavariati(dot)org>
To: pdxpug(at)postgresql(dot)org
Subject: Re: CASE eval issue
Date: 2011-10-18 23:30:52
Message-ID: 20111018233052.GE21112@kailarose.respond2.com (view raw or flat)
Thread:
Lists: pdxpug
On Tue, Oct 18, 2011 at 03:42:10PM -0700, David E. Wheeler wrote:
> On Oct 18, 2011, at 3:31 PM, Aaron Burt wrote:
> 
> > Query:
> > select id,
> >   case has_column_privilege('mytable', 'secure_column', 'SELECT')
> >     when FALSE then 'NA'
> >     else secure_column
> >   end as secure_column
> >  from mytable where id=12345;
> > 
> Try this:
> 
> select id,
>   case when has_column_privilege('mytable', 'secure_column', 'SELECT')
>     then 'NA'
>     else secure_column
>   end as secure_column
>  from mytable where id=12345;

Not sure I follow you.  Your version appears to reverse the condition.
I did also use the 'case when (condition) then ...' form but as one would
expect, it acted the same.  I also used explicit cases for TRUE and FALSE.

Thanks,
  Aaron

In response to

Responses

pdxpug by date

Next:From: David E. WheelerDate: 2011-10-19 02:24:08
Subject: Re: CASE eval issue
Previous:From: David E. WheelerDate: 2011-10-18 22:42:10
Subject: Re: CASE eval issue

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