Re: Cast NULL into Timestamp?

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Wei Weng <wweng(at)kencast(dot)com>, "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Cast NULL into Timestamp?
Date: 2004-12-11 00:10:16
Message-ID: 200412101610.16959.scrawford@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Friday 10 December 2004 11:24 am, Wei Weng wrote:
> I have a table
>
> create table temp
> (
> tempdate timestamp,
> tempname varchar(10)
> );
>
> And I tried to insert the following:
>
> insert into table temp (tempname, tempdate)
> select distinct 'tempname', null from some_other_relevant_table;
>
> And I got an error that says "column "tempdate" is of type
> timestamp ... but expression is of type text... will need to
> rewrite or cast the expression".
>
> I really need the distinct. Is there anyway to cast this NULL into
> a timestamp or any other workarounds?

How about:
insert into table temp (tempname)
select distinct 'tempname' from some_other_relevant_table;

Unless there's something you have left out in describing your setup
this will leave the tempdate column null.

Cheers,
Steve

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2004-12-11 00:48:24 Re: Cast NULL into Timestamp?
Previous Message Josh Berkus 2004-12-10 23:42:18 Re: Indexing Strategy