DB2 ODBC/CLI Common Errors

Mindwatering Incorporated

Author: Tripp W Black

Created: 11/24/2004 at 12:43 PM

 

Category:
DB2 Tips
DB2 SQL Queries

Error Message:
LS:DO - Field ID is out of range.
LS:DO - The field ID is invalid or beyond the number of columns in the result set..

Solution:
You are specifying a value into a column that doesn't exist in the table or unavailable. Most likely this is a missspelled column name.
e.g.
Call result.AddRow()
Call result.SetValue("NAEM", myname) // "NAEM" should be "NAME"


Error Message:
LS:DO - Never executed successfully or result set closed.
LS:DO - The requested operation cannot be completed because it requires the successful execution of a query. A query may fail if the SQL statement was in error. Close the result set discards its data.

Solution:
This occurs when you try to do a "second" command that builds upon a former one that actually failed. For example, this happened to me when I misspelled the name of the table for my SELECT statement. When the table was retrieved, nothing really was returned. When I attempted to add a new row, I received this error.
e.g.
qry.SQL="SELECT * FROM IS001.MYTABEL" // mispelled MYTABLE
Set result.Query = qry
Call result.Execute() // no error is triggered here, even though I messed up the name of the table
Call result.AddRow() // the error is triggered here


Error Message:
LS:DO - ODBC could not complete the requested operation.
[IBM][CLI DRIVER][DB2/NT] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" contrains table "IS001.MYTABLE" from having duplicate rows for those columns.

Solution:
This occurs when you try to insert a new row into a table and the new row's key(s) are not unique. This generally happens when migrate data during a test and then forget to remove the previous table data before running the code again. You must make sure that the "next" row that you are inserting is unqiue. If this is not a "duh" error, then doe one of the following:
1. If the key is a incremental one, get the last row and increment the appropriate key before writing the new row.
2. If the data being added is supposedly a unique string, test by doing a SELECT with that key to see if the row already exists.


Error Message:
LS:DO - ODBC could not complete the requested operation.
[IBM][CLI DRIVER] CLI0109E String data right truncation.

Solution:
This occurs when you try to insert a new row into a table and one of the values of the columns to add has too many characters. Trim down to the correct number of characters for that column before doing the Insert command.
e.g.
result.SetValue("MyColumn", Left(someval, 5))
Call result.UpdateRow()


Error Message:
LS:DO - ODBC could not complete the requested operation.
[IBM][CLI DRIVER] SQL0010N The string constant beginning with ... ... does not have an ending string deliminator.

Solution:
This occurs when you leave off a single quote from the beginning or ending of a value being added to a column of a row. Check each of your values to make sure that each string constant has both a beginning and ending single quote. If it is a numerical Integer or Small Integer value, leave off the single quotes.)





previous page

×