Re: ::text problem

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg>, "psql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: ::text problem
Date: 2003-11-25 16:14:16
Message-ID: 200311251614.16957.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael A Nachbaur 2003-11-25 16:55:13 "Permission denied" on view
Previous Message Kumar 2003-11-25 12:37:58 ::text problem