Re: [GENERAL] Confused about CASE

2008-02-29 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > It looks like the problem is that relkind is of the somewhat odd > PostgreSQL type "char" not an actual char(1), so with the else in there it > appears to try to force the unknown literals into that type which only > takes the first character. It will pro

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Thomas Kellerer
Adam Rich wrote on 01.03.2008 01:02: "The data types of all the result expressions must be convertible to a single output type." The type of the field pg_class.relkind appears to be "char" which is described in the notes as: The type "char" (note the quotes) is different from char(1) in that i

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Adam Rich
> "The data types of all the result expressions must be convertible to a > single output type." The type of the field pg_class.relkind appears to be "char" which is described in the notes as: The type "char" (note the quotes) is different from char(1) in that it only uses one byte of storage. It

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Stephan Szabo
On Sat, 1 Mar 2008, Thomas Kellerer wrote: > I was writing a statement retrieve dependency information out of the > system catalog, when I noticed something that I didn't expect. > > I wanted to use the following statement to "translate" the relkind > column to a more descriptive value: > > selec

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Adam Rich
> I wanted to use the following statement to "translate" the relkind > column to a > more descriptive value: > > select c.relname > case > when c.relkind in ('t','r') then 'table' > when c.relkind = 'i' then 'index' > when c.relkind = 'S' then 'sequence' >

[GENERAL] Confused about CASE

2008-02-29 Thread Thomas Kellerer
Hello, I was writing a statement retrieve dependency information out of the system catalog, when I noticed something that I didn't expect. I wanted to use the following statement to "translate" the relkind column to a more descriptive value: select c.relname case when c.relk