Re: DISTINCT with NULLs and INT fields - Mailing list pgsql-sql

From George Pavlov
Subject Re: DISTINCT with NULLs and INT fields
Date
Msg-id CCB89282FCE1024EA3DCE687A96A5164039EC5FE@ehost010-6.exch010.intermedia.net
Whole thread Raw
In response to DISTINCT with NULLs and INT fields  ("George Pavlov" <gpavlov@mynewplace.com>)
Responses Re: DISTINCT with NULLs and INT fields  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-sql
> Sure, but in this example the required type of the value is clear from
> immediate context (ie, the INSERT).  This is one of the cases where
> the SQL spec requires a bare NULL to be accepted.  (BTW, 'no' and '4'
> in this example are *not* values of type text; they are
> untyped literals which we eventually resolve as varchar or int.)

hmmm... with the risk of boring everyone to tears:

test=# insert into foo values (4::int,4::int);
INSERT 0 1
test=# insert into foo values (4::text,4::text);
ERROR:  column "b" is of type integer but expression is of type text
HINT:  You will need to rewrite or cast the expression.
test=# insert into foo values (cast(4 as int),cast(4 as int));
INSERT 0 1
test=# insert into foo values (cast(4 as text),cast(4 as text));
ERROR:  column "b" is of type integer but expression is of type text
HINT:  You will need to rewrite or cast the expression.

(i actually think it is important to understand how this stuff works and
thanks for explaining!)


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: DISTINCT with NULLs and INT fields
Next
From: Alvaro Herrera
Date:
Subject: Re: DISTINCT with NULLs and INT fields