Re: [EXTERNAL] Pgsql error in coalesce - Mailing list pgsql-novice

From Chamath Sajeewa
Subject Re: [EXTERNAL] Pgsql error in coalesce
Date
Msg-id CACpofehkYKLsr5DwvAqLjKMaLYAU9T1hJTh6D3OPS68oKynbtQ@mail.gmail.com
Whole thread Raw
In response to Pgsql error in coalesce  (Chamath Sajeewa <csgsajeewa@gmail.com>)
Responses Re: Pgsql error in coalesce  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-novice
Hi,
I thought it check the data type of the specified column. Isn't it the case here?

On Mon, 27 Jul 2020, 22:57 Vianello, Dan A, <Dan.Vianello@charter.com> wrote:

Your column name “column_name” is of type text. The number 255 is an integer.  Since those datatypes don’t match the coalesce function fails.  If the data in “column_name” can always be cast to an integer then you can use

 

Select coalesce(column_name::integer, 255);

 

Or you can cast 255 to a text string of ‘255’ with this:

Select coalesce(column_name, '255'::text);

 

 

The contents of this e-mail message and
any attachments are intended solely for the
addressee(s) and may contain confidential
and/or legally privileged information. If you
are not the intended recipient of this message
or if this message has been addressed to you
in error, please immediately alert the sender
by reply e-mail and then delete this message
and any attachments. If you are not the
intended recipient, you are notified that
any use, dissemination, distribution, copying,
or storage of this message or any attachment
is strictly prohibited.

pgsql-novice by date:

Previous
From: "Vianello, Dan A"
Date:
Subject: RE: [EXTERNAL] Pgsql error in coalesce
Next
From: David Raymond
Date:
Subject: RE: Pgsql error in coalesce