agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@lists.postgresql.org
Subject: Re: Implicit typecast behavior
Date: Tue, 23 Jul 2019 13:46:09 +0200
Message-ID: <79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net> (raw)
In-Reply-To: <MN2PR04MB58068FFFAC2102C68FAF1945C1C70@MN2PR04MB5806.namprd04.prod.outlook.com>
References: <MN2PR04MB58068FFFAC2102C68FAF1945C1C70@MN2PR04MB5806.namprd04.prod.outlook.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net>
Permalink:  ../79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net/
Also on:    postgresql.org/message-id/79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spam_eater@gmx.net, pgsql-sql@lists.postgresql.org
  Subject: Re: Implicit typecast behavior
  In-Reply-To: <79bd73eb-5475-5e1f-8999-070db1725f63@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox