Re: Auomatic numbering, replacing nulls and IF - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Auomatic numbering, replacing nulls and IF
Date
Msg-id 20020320083324.C45997-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Auomatic numbering, replacing nulls and IF  ("Pestilence" <me@work.com>)
List pgsql-general
On Fri, 15 Mar 2002, Pestilence wrote:

> 2) The ISNULL function in both Oracle and MS-SQL takes 2 numbers and returns
> the second if the first is null, otherwise it returns the first. ISNULL in
> Postgres seems to be something quite different. Before I go writing my own
> function to do it, is there one already?
>

Coalesce

> 3) How do I do 'IF this_sql THEN that_sql'? I keep getting:
> parse error at or near "IF"

In what context?
If you mean like
IF (select * from foo) then delete from foo
kind of context, that kind of thing is availble
via pl functions but not AFAIK via direct sql.

If you mean in a select list:
select (if a is 2 then 3 else 1)
you can use CASE.



pgsql-general by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: R: Bad timestamp external representation '2001-05-11
Next
From: Stephan Szabo
Date:
Subject: Re: no quotes in arrays in 7.2