X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99BFC3AA73A for ; Sat, 11 Dec 2004 01:47:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63476-09 for ; Sat, 11 Dec 2004 01:47:13 +0000 (GMT) Received: from polaris.pinpointresearch.com (66-7-238-130.cust.telepacific.net [66.7.238.130]) by svr1.postgresql.org (Postfix) with ESMTP id 497913AA991 for ; Sat, 11 Dec 2004 00:10:17 +0000 (GMT) Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 29D11103F2; Fri, 10 Dec 2004 16:10:17 -0800 (PST) From: Steve Crawford Organization: Pinpoint Research To: Wei Weng , "'pgsql-sql@postgresql.org'" Subject: Re: Cast NULL into Timestamp? Date: Fri, 10 Dec 2004 16:10:16 -0800 User-Agent: KMail/1.5.1 References: <41B9F808.2040909@kencast.com> In-Reply-To: <41B9F808.2040909@kencast.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200412101610.16959.scrawford@pinpointresearch.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/55 X-Sequence-Number: 19675 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