Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion error on host variable or parameter *N

I am getting this Error on Insert statement to AS400 database, using Java with JDBC.

like image 898
Richipal Avatar asked Sep 10 '09 17:09

Richipal


2 Answers

I figured it out, I had a numeric field with length 4 and decimal digits 2, In my insert I was trying to insert 100 in this numeric field which gave this error.

I altered the table and made it numeric with length 9 and decimal digits 2 
and the insert worked.

even though the error says "Conversion error", actually its the wrong field length.

like image 80
Richipal Avatar answered Sep 17 '22 13:09

Richipal


I ran in to this issue when a table was updated from 2 digits to 3 for user ID's and the query inserts in to a history table where the history table was not updated to 3 digits for the user id. Used Alter Table to correct the history table and all is well.

alter table "Table Name" ALTER COLUMN "COLUMN NAME" SET DATA TYPE NUMERIC(3)

The error message is not intuitive:

Conversion error on variable or parameter *N (#-302) [IBM][System iAccess ODBC Driver][DB2 for i5/OS]SQL0012 - Correlation without qualification occurred for column "columnname" to table "Tablename". (#12)

like image 38
user2208599 Avatar answered Sep 21 '22 13:09

user2208599