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)