explicit cast for null::bigint

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: explicit cast for null::bigint
Date: 2010-03-13 11:22:48
Message-ID: 20100313122248.3c3c5394@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've found this a bit strange:

insert into catalog_related (itemid, related_itemid, rank)
select distinct itemid, null::bigint, 0::float4
from catalog_categoryitem
where catid is null or catid<>0
and itemid not in (select itemid from
catalog_related);

create table catalog_related (
itemid bigint,
updated timestamp default now(),
related_itemid bigint,
rank float4
);

without the explicit cast for the null I get

ERROR: column "related_itemid" is of type bigint but expression is
of type text LINE 1: insert into catalog_related (itemid,
related_itemid, rank) ^

HINT: You will need to rewrite or cast the expression.
PostgreSQL 8.3.4 on x86_64-pc-linux-gnu

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Browse pgsql-general by date

  From Date Subject
Next Message Angel 2010-03-13 11:54:09 Hints for postgresql package recompilation (FIXED)
Previous Message Scott Marlowe 2010-03-13 09:24:56 Re: hardware for a server