Search code examples
databasetimestampintegerhana

ERROR 266: Inconsistent Datatype: TIMESTAMP type is incompatible with INT type SAP HANA


I am trying to transfer a source table A on SAP HANA to another target table B.

Both tables have the same structure below; they both have a column LASTUPDATE which is of type TIMESTAMP, but when I try to execute

Insert into TABLE B (Select BASE1,BASE2,LASTUPDATE from TABLE A) 

there is this error:

ERROR 266: Inconsistent Datatype: TIMESTAMP type is incompatible with INT type

Structure of table A:

The structure of SOURCE TABLE

Structure of table B:

The structure of TARGET TABLE

It is maybe a bug, do you have any idea how to solve this problem?

It looks like it is reading LASTUPDATE on TARGET as an INT, but I checked the structure it is of type TIMESTAMP and Modified it to type Date and To_SecondDate, I have the same error it is read as INT.

insert into wctversion (SELECT base1,base2,base3,base4,lastupdate,
schname,status,updateuser FROM TMP_wctversion)

It shows this ERROR:

Could not execute 'insert into wctversion (SELECT base1,base2,base3,base4,lastupdate,schname,status,updateuser FROM ...' SAP DBTech JDBC: [266]: inconsistent datatype: TIMESTAMP type is incompatible with INT type: line 1 col 57 (at pos 56)


Solution

  • As per the comment from @a_horse_with_no_name you have not specified the traget fields, so the system is trying to allocate the fields sequentially.

    In your case that means you're trying to insert LASTUPDATE into BASE3 - hence the conversion error.

    You should have:

    INSERT INTO B ("BASE1", "BASE2", "LASTUPDATE") (SELECT "BASE1", "BASE2", "LASTUPDATE" FROM A)