explicit cast for null::bigint - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject explicit cast for null::bigint
Date
Msg-id 20100313122248.3c3c5394@dawn.webthatworks.it
Whole thread Raw
List 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


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: hardware for a server
Next
From: Angel
Date:
Subject: Hints for postgresql package recompilation (FIXED)