This error typically occurs when using a PreparedStatement batch.
The Teradata Database requires that all parameter values in batch that are bound to the same parameter marker must be the same data type.
In other words, when your application binds multiple rows of data in a PreparedStatement batch, you must ensure that on a column-by-column basis, all column values are the same data type.
Important: This includes NULLs.
Your application will typically bind non-null values using the data-type-specific PreparedStatement setter methods such as setInt, setString, etc. But your application will typically bind null values using setNull. With setNull, you must specify the data type using a constant from java.sql.Types.
Example 1 -- how to cause this error -- bind two different data types to the same parameter marker:
PreparedStatement ps = con.prepareStatment("insert into mytable(column1) values(?)";
ps.setInt(1, 12345);
ps.addBatch();
ps.setString(1, "oops");
ps.addBatch();
Example 2 -- how to cause this error -- bind null and non-null with two different data types to the same parameter marker:
PreparedStatement ps = con.prepareStatment("insert into mytable(column1) values(?)";
ps.setInt(1, 12345);
ps.addBatch();
ps.setNull(1, Types.VARCHAR);
ps.addBatch();
This error typically occurs when using a PreparedStatement batch.
The Teradata Database requires that all parameter values in batch that are bound to the same parameter marker must be the same data type.
In other words, when your application binds multiple rows of data in a PreparedStatement batch, you must ensure that on a column-by-column basis, all column values are the same data type.
Important: This includes NULLs.
Your application will typically bind non-null values using the data-type-specific PreparedStatement setter methods such as setInt, setString, etc. But your application will typically bind null values using setNull. With setNull, you must specify the data type using a constant from java.sql.Types.
Example 1 -- how to cause this error -- bind two different data types to the same parameter marker:
PreparedStatement ps = con.prepareStatment("insert into mytable(column1) values(?)";
ps.setInt(1, 12345);
ps.addBatch();
ps.setString(1, "oops");
ps.addBatch();
Example 2 -- how to cause this error -- bind null and non-null with two different data types to the same parameter marker:
PreparedStatement ps = con.prepareStatment("insert into mytable(column1) values(?)";
ps.setInt(1, 12345);
ps.addBatch();
ps.setNull(1, Types.VARCHAR);
ps.addBatch();