| From: | José Soares <jose(at)sferacarta(dot)com> | 
|---|---|
| To: | Brian <signal(at)shreve(dot)net> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: [GENERAL] Does Postgres supoort this type? | 
| Date: | 1999-04-16 12:27:19 | 
| Message-ID: | 37172CA7.6369B360@sferacarta.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Use this:
--iif(expr,par1,par2): returns par1 if expr is true otherwise returns par2
drop function iif(bool,text,text);
create function iif(bool,text,text) returns text as
'
begin
        IF $1 THEN
            RETURN $2;
        ELSE
            RETURN $3;
        END IF;
 end;
' language 'plpgsql';
select iif('true','verdad','mentira');
select iif(1=1,'verdad','mentira');
select iif(2=1,'verdad','mentira');
select iif(2>1,'verdad','mentira');
select iif(2<1,'verdad','mentira');
José
Brian ha scritto:
> Does postgres support queries of type:
>
> update table set foo=$bar,baz= if(goober is null, 1, goober+1);
>
> If so, what is the correct syntax?  I was unable to find anything in the
> Postgres html documentation.
>
> -----------------------------------------------------
> Brian Feeny (BF304)     signal(at)shreve(dot)net
> 318-222-2638 x 109      http://www.shreve.net/~signal
> Network Administrator   ShreveNet Inc. (ASN 11881)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oleg Broytmann | 1999-04-16 13:05:07 | Optimal indicies | 
| Previous Message | The Hermit Hacker | 1999-04-16 12:09:11 | Re: [GENERAL] The WWW of PostgreSQL |