Re: ::text problem - Mailing list pgsql-sql

From Richard Huxton
Subject Re: ::text problem
Date
Msg-id 200311251614.16957.dev@archonet.com
Whole thread Raw
In response to ::text problem  ("Kumar" <sgnerd@yahoo.com.sg>)
List 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


pgsql-sql by date:

Previous
From: "Kumar"
Date:
Subject: ::text problem
Next
From: Michael A Nachbaur
Date:
Subject: "Permission denied" on view