Re: How to pickup null values in SQL Language?

From: Tahira Aslam <tahira_aslam(at)yahoo(dot)com>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to pickup null values in SQL Language?
Date: 2002-05-31 06:18:38
Message-ID: 20020531061838.68086.qmail@web11005.mail.yahoo.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general


thanks Mr.Stephen your solution solved my problem. But now I want to use COALASCE function in a function which uses 'plpgsql' language.(function needs to perform same functionality as it was in SQL language)
Select cast(MyView."Document_ID" as
Text)||','||cast(MyView."First_Name" as
Text)||','||cast(MyView."Last_Name" as
Text)||','||Coalesce(cast(MyView."Sent_Date" as Text),'NONE') From "MyView"
Where "Document_ID"=$1;
Language 'plpgsql';

But it gives error "Bad date external representation 'NONE' "....

is it some syntax mistake or what ?

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> wrote:
On Thu, 30 May 2002, Tahira Aslam wrote:

> Select Coalesce(cast(MyView."Document_ID" as
> Text)||','||cast(MyView."First_Name" as
> Text)||','||cast(MyView."Last_Name" as
> Text)||','||cast(MyView."Sent_Date" as Text),'NONE') From "MyView"
> Where "Document_ID"=$1;

If you want a part of the string to become NONE if null, you need
to coalesce each part (I'm dropping the casts for now):
select coalesce(MyView."Document_ID", 'None') || ',' ||
coalesce(MyView."First_Name", 'None') || ...

---------------------------------
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-05-31 06:30:06 Re: How to pickup null values in SQL Language?
Previous Message Stephan Szabo 2002-05-31 05:54:56 Re: How to pickup null values in SQL Language?