Reputation: 1789
I am running some DB2 queries and after that I am calling a PL sql procedure
calling of Procedure is
CallableStatement callStmt = con.prepareCall( //
"CALL INIT_PAYROLL(?,?,?,?,?,?,?,?,?,?)");
// Set IN parameters
callStmt.setString(1, start_date);//IN
callStmt.setString(2, end_date); //IN
callStmt.setInt(3, customer_id);//IN
callStmt.setString(4, payrollMain_id+"");//IN
callStmt.setString(5, ruleFreq );//IN
callStmt.setInt(6, 0);
callStmt.setString(7, outerArray);//IN
callStmt.setString(8, commsSepEmps);//IN
callStmt.setInt(9, isIncremental);
callStmt.registerOutParameter (10, Types.VARCHAR);
//Call the procedure
callStmt.executeUpdate();
toReturnStatus = callStmt.getString(10);
System.out.println("OutPutResult-- : " + toReturnStatus);
But some strange problem I am facing. I am clueless about why that is happening.
Another Question is if I call this procedure from within of Java files, and If an exception occurs in PLSql procedure, will the exception be printed as DB2 exception?
Error :
[2/27/15 17:00:15:778 IST] 0000280f SystemErr R com.ibm.db2.jcc.am.SqlDataException: DB2 SQL Error: SQLCODE=-433, SQLSTATE=22001, SQLERRMC=129727:12068,133389:12069,133390:12070,133391:12071,133393:1, DRIVER=3.62.56
in this error 129727:12068 , is employee_id:primaryKeyOFtable ,
EDIT : The SP don't give problem in every case, I pass comma separated employeeIds in SP, only when it exceeds some certain limit/length, it fails and give this error.
EDIT I solved/found the error, Actually I was passing a String whose length was exceeding the defined VarChar limit. :)
Upvotes: 1
Views: 2167
Reputation: 618
22001 means Character data, right truncation occurred; for example, an update or insert value is a string that is too long for the column, or a datetime value cannot be assigned to a host variable, because it is too small.
Here is the link with different DB2 error codes https://urssanj00.wordpress.com/2008/03/04/db2-sql-error-code-and-description/
Upvotes: 1