user3601704
user3601704

Reputation: 763

Error of SQL query on IBM netezza SQL database from Aginity workbench on Win7

I need to so a sql query on IBM netezza sql database from Aginity workbench on win7.

My query:

 SELECT *
 from table1 AS c , 
      table2 AS  b
where  CAST(c.id as int) = b.id

in table1, id is character varying(20) and in table2, id is int.

Table1: 

 id    value1        value2
'985'  'casdqwdc'   '654.3184'  // they are all char

Table2: 

id    value1        
985   694381   // id is int, value1 is int

I got error:

  ERROR [HY000] ERROR:  pg_atoi: error in "id": can't parse "id"

Any help would be appreciated.

Upvotes: 1

Views: 1821

Answers (1)

ScottMcG
ScottMcG

Reputation: 3887

Somewhere in column ID in table1 there is a value that can't be converted to an integer.

Based on the error, you have probably used nzload or an external table to load a data file that has a header row with column labels without skipping that row, and you have 1 row with the value 'ID' in the column ID.

TESTDB.ADMIN(ADMIN)=> select CAST('ID' as int);
ERROR:  pg_atoi: error in "ID": can't parse "ID"

Upvotes: 1

Related Questions