Re: CASE in where statement. BUG ?? - Mailing list pgsql-general

From Alexander Litvinov
Subject Re: CASE in where statement. BUG ??
Date
Msg-id 200312191455.32740.lan@ac-sw.com
Whole thread Raw
In response to CASE in where statement. BUG ??  (Marek Lewczuk <newsy@lewczuk.com>)
Responses Re: CASE in where statement. BUG ??  (Marek Lewczuk <newsy@lewczuk.com>)
List pgsql-general
This is normaol behavior.

> I belive that I have found a bug - or maybe it was done on purpose. Have
> a look at this query:
>
>
> SELECT integer_field FROM bugtable WHERE (CASE WHEN '' <> '' THEN
> integer_field = '' ELSE integer_field = 0 END);
> Result: ERROR:  invalid input syntax for integer: ""

Here CASE have int type and you are trying to cast '' to int. Error.

>
>
> SELECT text_field FROM bugtable WHERE (CASE WHEN '' <> '' THEN
> text_field = '' ELSE text_field = '1' END);
> Result: 1 rows fetched (0,02 sec)

Here CASE have text type. Everything is fine.


pgsql-general by date:

Previous
From: Marek Lewczuk
Date:
Subject: CASE in where statement. BUG ??
Next
From: Marek Lewczuk
Date:
Subject: Re: CASE in where statement. BUG ??