IBM Support

100 Tech Tips, #99 How to run REORG command from a CLI application?

Technical Blog Post


Abstract

100 Tech Tips, #99 How to run REORG command from a CLI application?

Body

How to run REORG table command from a CLI application against a DB2 database server?
 
REORG command is supported by command line processor, you cannot use the REORG command directly from a CLI application. In order to run REORG from a CLI application, you will have to use ADMIN_CMD stored procedure.

For example:
CALL SYSPROC.ADMIN_CMD ('REORG TABLE test')
 
 
If you try to use the REORG command from a CLI application, it will return SQL0104N (syntax error). You will find a SQL0104N in the CLI trace captured while reproducing the issue from the application.
                                                                                                   
The same REORG command when issued from the command line executes successfully.

For example:
db2 "reorg table test"                                    
DB20000I  The REORG command completed successfully.                                        
 

[{"Business Unit":{"code":"BU029","label":"Data and AI"}, "Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":""}]

UID

ibm11141768