RE: Pgsql error in coalesce - Mailing list pgsql-novice

From Stephen Froehlich
Subject RE: Pgsql error in coalesce
Date
Msg-id CH2PR06MB64706ABCFCB27BAACBC50BD8E5720@CH2PR06MB6470.namprd06.prod.outlook.com
Whole thread Raw
In response to Pgsql error in coalesce  (Chamath Sajeewa <csgsajeewa@gmail.com>)
Responses Re: Pgsql error in coalesce  (Chamath Sajeewa <csgsajeewa@gmail.com>)
List pgsql-novice

What do you get with the following two type castings:

 

SELECT coalesce(column_name::integer, 255); ?

SELECT coalesce(column_name, ‘255’::text)::integer; ?

 

“integer” might actually be “smallint” if you’re only going to 255.

 

--Stephen

 

From: Chamath Sajeewa <csgsajeewa@gmail.com>
Sent: Monday, July 27, 2020 10:51
To: pgsql-novice@lists.postgresql.org
Subject: Pgsql error in coalesce

 

Hi,

There is table with int4 column. When select query is executed as "select coalesce(column_name, 255), query is failing with below error.

"COALESCE types text and integer cannot be mached".

Any idea?

Thank You!!

pgsql-novice by date:

Previous
From: Chamath Sajeewa
Date:
Subject: Pgsql error in coalesce
Next
From: Chamath Sajeewa
Date:
Subject: Re: Pgsql error in coalesce