【DB2】How to resolve SQL20249N the statement was not processed with error

时间:2022-02-22 10:51:38

相关链接

https://vinaysdb2blog.blogspot.com/2017/11/how-to-resolve-sql20249n-statement-was-not-processed-error.html

转载

https://www-01.ibm.com/support/docview.wss?uid=swg22002381

Technote (troubleshooting)

Problem(Abstract)

In this scenario you perform a restore of a database from a backup image. When the restore completes you receive the error SQL20249N running commands on the database.

Symptom
You are restoring from a database backup image with a higher Fix Pack number than the instance it is being restored to, as shown by the example db2diag.log below.

2017-04-21-12.50.46.077587-240 I235453E572 LEVEL: Severe
PID : 15273 TID : 46914280089920 PROC : db2sysc
INSTANCE: db2inst1 NODE : 000 DB : SAMPLE
APPHDL : 0-10 APPID: LOCAL.db2inst1.170421085044
AUTHID : DB2INST1 HOSTNAME: testserver
EDUID : 582 EDUNAME: db2agent (SAMPLE)
FUNCTION: DB2 UDB, catalog services, sqlrlGetVersionTimes, probe:180
MESSAGE : Database release: 10050700 ==> Database is now moved back to the
​ current DB2 release level of 10050600*

When running the query below...

db2 "select varchar(pkgschema,16),varchar(pkgname,16),valid from syscat.packages where pkgschema='NULLID' and pkgname='SQLUAK20'"

You receive the error below...

SQL20249N The statement was not processed because the package named "NULLID.SQLC2K26" needs to be explicitly rebound.

Cause

Downgrade of database to a lower Fix Pack through a restore causes packages to become invalid. Packages in a later Fix Pack may have certain differences from those in a previous Fix Pack, so if a database is downgraded, the packages are initially set as invalid, forcing the need for those invalid packages to go through the "rebind" action.

Diagnosing the problem
Check the db2diag.log after the restore to see there is an entry like the one above shown in the Symptom.

After a restore you would see error SQL20249N when trying to run commands on the database.

(See example in Symptom).

Resolving the problem

Explicitly rebind packages by performing the below commands.

db2 connect to SAMPLE

db2 rebind <package name> RESOLVE CONSERVATIVE

or

db2 -x "select 'REBIND PACKAGE ' || rtrim(pkgschema) || '.' || rtrim(pkgname) || ';' as command from syscat.packages" > rebind.sql

db2 -tvf rebind.sql

And then try the command.

db2 " select pkgschema,pkgname,valid from syscat.packages where pkgschema='NULLID' and pkgname='SQLUAK20' "

The query should work without error SQL20249N.