Re: [GENERAL] Does Postgres supoort this type? - Mailing list pgsql-general

From José Soares
Subject Re: [GENERAL] Does Postgres supoort this type?
Date
Msg-id 37172CA7.6369B360@sferacarta.com
Whole thread Raw
In response to Does Postgres supoort this type?  (Brian <signal@shreve.net>)
List 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@shreve.net
> 318-222-2638 x 109      http://www.shreve.net/~signal
> Network Administrator   ShreveNet Inc. (ASN 11881)


pgsql-general by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [GENERAL] The WWW of PostgreSQL
Next
From: Oleg Broytmann
Date:
Subject: Optimal indicies