[Info-ingres] When is an empty string an integer?

Laframboise, André (BAC/LAC) andre.laframboise at canada.ca
Wed May 11 13:21:05 UTC 2016


Looks like another case of multiple standards, just like everything else in life......

From: info-ingres-bounces at lists.planetingres.org [mailto:info-ingres-bounces at lists.planetingres.org] On Behalf Of Martin Bowes
Sent: Wednesday, May 11, 2016 9:17 AM
To: Ian Kirkham <Ian.Kirkham at actian.com>; info-ingres at lists.planetingres.org
Subject: Re: [Info-ingres] When is an empty string an integer?

Hi Ian,

I don't see this as a bug, just a state of play. Might be a good idea for it to be documented in the SQL guide somewhere but that's as far as I'd go.

FYI. Geraint Jones has informed me that:
Various DBMS's disagree on how to handle cast('' as integer).

Ingres : 0.
Oracle : NULL.
Postgres : Error.
MySQL : 0.

Marty

From: Ian Kirkham [mailto:Ian.Kirkham at actian.com]
Sent: 11 May 2016 13:51
To: Martin Bowes; info-ingres at lists.planetingres.org<mailto:info-ingres at lists.planetingres.org>
Subject: RE: [Info-ingres] When is an empty string an integer?

Hi Marty,
Historically Ingres has always treated a string of just zero or more space characters as numeric 0 on conversion to integers.
MS excel does the same so it must be an industry standard - :)
Not something we could easily correct now.
Regards,
Ian
From: info-ingres-bounces at lists.planetingres.org<mailto:info-ingres-bounces at lists.planetingres.org> [mailto:info-ingres-bounces at lists.planetingres.org] On Behalf Of Martin Bowes
Sent: 11 May 2016 13:42
To: info-ingres at lists.planetingres.org<mailto:info-ingres at lists.planetingres.org>
Subject: [Info-ingres] When is an empty string an integer?

Hi All,

This is probably documented behaviour but I'm having a hard time finding it. So if someone could point me at the document I'd be happy.

What is the expected result of: select integer(varchar('', 1))

The answer is zero.

I must concede I can sort of see this as being necessary, but I'm curious as to why we just didn't get the standard error:
E_US100F String cannot be converted to numeric due to incorrect syntax.

Martin Bowes




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.planetingres.org/pipermail/info-ingres/attachments/20160511/4112a741/attachment.html>


More information about the Info-ingres mailing list