X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5B659D1CA61 for ; Tue, 25 Nov 2003 16:16:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88910-10 for ; Tue, 25 Nov 2003 12:16:00 -0400 (AST) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 5A408D1DB38 for ; Tue, 25 Nov 2003 12:14:35 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1AOfpV-0005Ep-0Y; Tue, 25 Nov 2003 16:14:21 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 63D7D178F1; Tue, 25 Nov 2003 16:14:19 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id C1616178EF; Tue, 25 Nov 2003 16:14:17 +0000 (GMT) From: Richard Huxton To: "Kumar" , "psql" Subject: Re: ::text problem Date: Tue, 25 Nov 2003 16:14:16 +0000 User-Agent: KMail/1.5 References: <037f01c3b350$fa38ae00$7502a8c0@hdsc.com> In-Reply-To: <037f01c3b350$fa38ae00$7502a8c0@hdsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200311251614.16957.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/282 X-Sequence-Number: 16097 On Tuesday 25 November 2003 12:37, Kumar wrote: > > SELECT > CASE WHEN c1 IS NULL THEN 'Record_Not_Found'ELSE c1 END as > approval_date FROM t1; > ERROR: Bad timestamp external representation 'Record_Not_Found' > > > SELECT > CASE WHEN c1 IS NULL THEN 'Record_Not_Found'::text ELSE c1 END as > approval_date FROM t1; > ERROR: CASE types 'timestamp without time zone' and 'text' not matched Almost - you're on the right lines. Try: SELECT CASE WHEN c1 IS NULL THEN 'Record_Not_Found'::text ELSE c1::text END as approval_date FROM t1; You need to make sure both options return type text. -- Richard Huxton Archonet Ltd