IBM Support

Casting a Double as Int

Troubleshooting


Problem

Prior to Netezza 5.2, when casting a double value to an integer value, if the input is a number other than integer, the operation is not handled properly and causes an "ERROR: pg_atoi" parsing error.

Symptom

The following error appears:
system(admin)=> SELECT CAST(1.27e+2 AS int);
ERROR: pg_atoi: error in "1.27e+2": can't parse ".27e+2"
system(admin)=> SELECT 1.27e+2::int;
ERROR: pg_atoi: error in "1.27e+2": can't parse ".27e+2"


Resolving The Problem

As of Netezza 5.2, casting a double value to an integer value will cast the double to the nearest integral value as shown in the following examples:

KB(ADMIN)=> SELECT CAST(1.27e+2 AS int);
?COLUMN?
----------
127
(1 row)



KB(ADMIN)=> SELECT CAST(1.56 AS int);
?COLUMN?
----------
2
(1 row)



KB(ADMIN)=> SELECT 1.27e+2::int;
?COLUMN?
----------
127
(1 row)

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

NZ602627

Document Information

Modified date:
17 October 2019

UID

swg21574954