22 January 2009

IBM DB2 Error: SQLSTATE=55019; Table Cannot Be Accessed

Here is a wondeful error you might encounter throughout your IBM DB2 development experiences. As you probably do NOT already know, IBM DB2 8 does not support the TRUNCATE command, infact, you will get a wonderful syntax error if you attempt to use it.

So you browse the Internet and someone recommends that you use the ALTER TABLE command as follows:

ALTER TABLE SCHEMA.TABLE ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE

The above command will work just fine but what if you were using this command in a transaction and you rolled back the transaction? Guess what? You will get the following error:

com.ibm.db.DataException: A database manager error occurred. :
[IBM][CLI Driver][DB2/NT] SQL1477N Table "
SCHEMA.TABLE" cannot be
accessed. SQLSTATE=55019


Basically, what the above command is actually doing is that it is disabling logging for the table and then emptying it. If you read my
SQL: DELETE, DROP, TRUNCATE post, you will learn that logging is one of the important things that is needed for transactions to work.

So my disabling logging, your actually preventing the table from being rolled back to its original state from within your unit of work. Thus the cause of this error.

Solution
The best way to avoid this error is actually try and avoid in using this command in a transaction. If it is an absolute must to use it in a transaction and you run into this error, then the only solution is to DROP the table and recreate it. Oh and did I mention that this solution is straight from IBM's manual?

No comments:

Post a Comment

Feel free to write any comments or ideas!

IBM DB2 Error: SQLSTATE=55019; Table Cannot Be Accessed

Here is a wondeful error you might encounter throughout your IBM DB2 development experiences. As you probably do NOT already know, IBM DB2 8 does not support the TRUNCATE command, infact, you will get a wonderful syntax error if you attempt to use it.

So you browse the Internet and someone recommends that you use the ALTER TABLE command as follows:

ALTER TABLE SCHEMA.TABLE ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE

The above command will work just fine but what if you were using this command in a transaction and you rolled back the transaction? Guess what? You will get the following error:

com.ibm.db.DataException: A database manager error occurred. :
[IBM][CLI Driver][DB2/NT] SQL1477N Table "
SCHEMA.TABLE" cannot be
accessed. SQLSTATE=55019


Basically, what the above command is actually doing is that it is disabling logging for the table and then emptying it. If you read my
SQL: DELETE, DROP, TRUNCATE post, you will learn that logging is one of the important things that is needed for transactions to work.

So my disabling logging, your actually preventing the table from being rolled back to its original state from within your unit of work. Thus the cause of this error.

Solution
The best way to avoid this error is actually try and avoid in using this command in a transaction. If it is an absolute must to use it in a transaction and you run into this error, then the only solution is to DROP the table and recreate it. Oh and did I mention that this solution is straight from IBM's manual?

0 Comments:

Post a Comment

Feel free to write any comments or ideas!