Thursday 4 February 2016

[ERROR] Bad int8 external representation (SQL-HY000) - NETEZZA Sql

This is caused to due to invalid data getting queried in SELECT Query.

Common data errors:

1. For Integer/Decimal fields we are getting Character values.
2. Date or TimeStamp Datatype we are getting incorrect date formats or invalid characters.


For Instance,

We have two tables and have to do union on them.

TABLE A                                               TABLE B
COL1   VARCHAR                                COL1 VARCHAR
COL2   INTEGER                                   COL2  INTEGER
COL3   VARCHAR                                 COL3  VARCHAR
COL4   VARCHAR                                 COL4   VARCHAR


When we are doing Union of two datasets. If the column order is incorrect we would be be select wrong data for other datatype.
In below query, Integer datatype is getting mismatched with VARCHAR datatype.

This would lead to BAD INT8 error.


SELECT
COL1
COL2
COL3
COL4
FROM TABLE A

UNION

SELECT
COL1
COL3
COL2
COL4
FROM TABLE A


WORKAROUND:

Correct the SELECT order for all column in both the SQLs






No comments:

Post a Comment