From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Pestilence <me(at)work(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Auomatic numbering, replacing nulls and IF |
Date: | 2002-03-20 16:37:23 |
Message-ID: | 20020320083324.C45997-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Lockhart | 2002-03-20 16:41:43 | Re: R: Bad timestamp external representation '2001-05-11 |
Previous Message | Jan Wieck | 2002-03-20 16:37:20 | Re: Distributed databases and replication in postgresql 7.3 |