FAQ : Database (DB/2, ODBC, Oracle) : Q: Is there a way to perform a REORG TABLE command from VA Smalltalk DB2 CLI application?
Q: Is there a way to perform a REORG TABLE command from VA Smalltalk DB2 CLI application?
Problem
The REORG command can not be called directly from a CLI application. Using the SAMPLE database shipped with DB2 as an example, trying to do something like this:
anAbtIbmClliCSDatabaseConnection executeSQLStatement: ‘REORG TABLE BBRODD.EMPLOYEE’
results in the following error:
AbtError: rc=-1 for '42601' in an AbtIbmCliCSDatabaseConnection at (8/13/2013 10:07:11 PM) '[SQLSTATE=42601 - [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "BBRODD" was found following "REORG TABLE ". Expected tokens may include: "JOIN". SQLSTATE=42601 [Native Error=-104]].
The DB2 support site indicates that such calls are only supported in the db2 command line processor.
Solution
DB2 does provide a mechanism for making this type of call from a CLI application, but in an indirect manner using the ADMIN_CMD. To successfully perform the table reorg, you can execute the following SQL statement:
anAbtIbmClliCSDatabaseConnection executeSQLStatement:’Call ADMIN_CMD (“REORG TABLE BBRODD.EMPLOYEE”)’
 
Note:
There may be other ‘db2 command line processor only’ commands that can be executed in this manner.
 
 
 
Last modified date: 01/29/2015