> 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!) 

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to