SQLCODE -607: Operation not allowed on this object
SQLCODE -607 (SQLSTATE 42832) means the statement tried an operation or option Db2 doesn't allow on that object. On Db2 for z/OS it almost always involves the Db2 catalog (DSNDB06) or directory (DSNDB01).
Other names for this code
Also written as SQL -607, SQLCODE=-607, SQLCODE = -607, db2 -607, sqlstate 42832, SQL0607N, operation or option is not defined for this object.
What it means
Db2 keeps its own definitions in the catalog and its internal control data in the directory. You can read most of them with SQL, and some catalog changes are allowed, such as updating statistics columns. Many operations are blocked, though. When a statement tries one, Db2 rejects it with -607. The token names the operation or option.
The blocked operations include these.
- CREATE and DROP of objects in the catalog database, DSNDB06.
- LOGGED or NOT LOGGED on a catalog table space.
- Cloning a catalog or directory table.
- ALTER TABLE, ALTER TABLESPACE, DELETE, MERGE, UPDATE and RENAME on directory tables.
- Creating, altering, dropping or renaming indexes on directory tables.
- Using a directory table as a parent table in a foreign key, or as the table a trigger is defined on.
- ALTER TABLESPACE with MOVE TABLE on a catalog or directory table space.
- Changing the owner of most objects owned by SYSIBM or in a schema starting with SYS.
There is one less obvious case. A SELECT from a directory table has to run with UR isolation. If it sits inside a statement where Db2 can't run it as UR, such as a subquery in an UPDATE, you get -607.
Common causes
- A DDL script generated for all objects in the subsystem includes catalog or directory objects.
- Someone tries to clean up history with DELETE against a directory table such as SYSIBM.SYSLGRNX.
- A subquery against a directory table sits inside an UPDATE or DELETE, so Db2 can't read it with UR.
- An ALTER or TRANSFER OWNERSHIP targets an object owned by SYSIBM.
- A period specification is used on a table reference that isn't a table.
How to find the problem
- Read the operation token in the message.
- Check the target object. Look at DBNAME in SYSIBM.SYSTABLES or SYSIBM.
SYSINDEXES. DSNDB06 is the catalog and DSNDB01 the directory. - Look for subqueries that read SYSIBM tables inside data change statements.
- Check the creator or owner of the object. SYSIBM objects are system objects.
How to fix it
- Remove catalog and directory objects from generated DDL.
- Use the utility built for the job instead of SQL. MODIFY RECOVERY cleans up old recovery history in SYSIBM.SYSCOPY and SYSIBM.SYSLGRNX.
- Read directory data in a separate query with UR isolation, then use the results in your update.
- If an option isn't allowed for the object, drop that option and rerun. If the operation itself isn't allowed, there is no way to run it on that object.
IBM documentation
IBM documentation: -607. Use the documentation for your installed release.
Related codes
Questions
Can I update the Db2 catalog with SQL at all?
Some changes are allowed, such as updating statistics columns. Structural changes to catalog objects, and any data change or DDL on directory tables, are blocked and give -607. Reading directory tables with SELECT is allowed.
Is -607 the same on Db2 for LUW?
Yes. Db2 for LUW reports SQL0607N with SQLSTATE 42832 when an operation isn't defined for system objects.
Why does reading a directory table fail inside an UPDATE?
Db2 reads directory tables only with UR isolation. Inside an UPDATE or DELETE it can't do that, so the statement gets -607. Run the read as its own query.