From: | Daryl Richter <daryl(at)eddl(dot)us> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: bug with if ... then ... clause in views |
Date: | 2006-01-18 12:32:53 |
Message-ID: | C0455D84-6156-4777-9427-16E9B08E5296@eddl.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
On Jan 18, 2006, at 4:18 AM, Emil Rachovsky wrote:
> While trying to create some views I stumbled on some
> problem with using the if-then clause. Here is a
> simple example :
>
> CREATE OR REPLACE VIEW public.SomeView
> as select d.id,
> if (true) then d.DocNumber endif from
> public.Z_Documents as d;
>
> I get the following error :
> syntax error at or near "then" at character 72
>
> I don't have a clue what is going on here. Any
> suggestions?
I see 2 issues.
1) if *what* is true?
2) AFAIK, there is no IF conditional in SQL. Perhaps you want CASE?
e.g.
CREATE OR REPLACE VIEW SomeView
as
select
d.id,
case
when condition = true then d.doc_number
else 'Bad Doc'
end
from
documents as d;
go
>
> Thanks in advance,
> Emil
>
--
Daryl
"Stress rarely has a positive impact on our ability to think.
Never, I'd guess."
-- Ron Jeffries, 2005
From | Date | Subject | |
---|---|---|---|
Next Message | Rudolph | 2006-01-18 12:55:56 | Re: Error when inserting millions of records |
Previous Message | Martijn van Oosterhout | 2006-01-18 12:25:03 | Re: Partitioning: Planner makes no use of indexes on inherited |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2006-01-18 12:33:20 | Re: Matching several rows |
Previous Message | Volkan YAZICI | 2006-01-18 11:55:17 | Re: Matching several rows |