Re: [EXTERNAL] Pgsql error in coalesce

From: Chamath Sajeewa <csgsajeewa(at)gmail(dot)com>
To: "Vianello, Dan A" <Dan(dot)Vianello(at)charter(dot)com>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: [EXTERNAL] Pgsql error in coalesce
Date: 2020-07-27 17:32:42
Message-ID: CACpofehkYKLsr5DwvAqLjKMaLYAU9T1hJTh6D3OPS68oKynbtQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)Vianello(at)charter(dot)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.
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David Raymond 2020-07-27 17:33:09 RE: Pgsql error in coalesce
Previous Message Vianello, Dan A 2020-07-27 17:27:00 RE: [EXTERNAL] Pgsql error in coalesce