Re: Implicit typecast behavior

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: Implicit typecast behavior
Date: 2019-07-23 11:46:09
Message-ID: 79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Rick Vincent schrieb am 23.07.2019 um 13:22:
>
> I am looking for a way to make postgresql function as Oracle and
> other databases do with implicit typecasts. For example, in the
> query below:
>
> SELECT RECID, RANK FROM MYTABLE WHERE RANK > 12

I know that you probably don't want to hear this, but:

That is really bad coding style in Oracle just as well as in Postgres as well.

It was a bug waiting to happen in Oracle already - the query will fail if there is at least one row where RANK can not be converted to number.

The correct solution to that problem is to not store numbers in VARCHAR columns - full stop.
Don't do it. Not in Postgres not in any other database.

Do the right thing and convert that column to an integer column.

Thomas

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2019-07-23 14:31:05 Re: Implicit typecast behavior
Previous Message Sonnenberg-Carstens, Stefan 2019-07-23 11:29:06 AW: Implicit typecast behavior