Db2 SQLCODE

SQLCODE -812: Blank collection ID in CURRENT PACKAGESET

SQLCODE -812 (SQLSTATE 22508) means Db2 couldn't form a package name for the program because the last or only entry in the plan's package list uses * for the collection and the CURRENT PACKAGESET special register is blank. Db2 needs a real collection ID to look the package up.

Other names for this code

Also written as SQL -812, SQLCODE=-812, SQLCODE = -812, db2 -812, sqlstate 22508, blank collection-id current packageset, jdbc -812 DB2Binder.

What it means

A plan's package list (PKLIST) tells Db2 where to look for packages. An entry such as PAYCOLL.* names a collection. An entry such as *.* or *.PAYCALC leaves the collection open, and Db2 fills it in at run time from the CURRENT PACKAGESET special register. This lets one plan run packages from collections the program chooses, such as a test collection and a production one.

When the entry Db2 reaches is the last or only one in the list and it has * as the collection, the register must hold a collection ID. If it's blank, Db2 can't build a name at all, and the statement fails with -812. The message shows the program name with its consistency token and the plan name.

The same code also shows up with the IBM Data Server Driver for JDBC and SQLJ. The driver works through a fixed set of packages, and an application that keeps too many statement objects open at once can use them all.

Common causes

  • The plan was bound with PKLIST(*.*) or with a *.program entry, and the program never sets CURRENT PACKAGESET.
  • The program sets CURRENT PACKAGESET on one path but not on another, such as an error or restart path.
  • Code set the register back to blank, for example after switching collections for one call.
  • A REBIND of the plan removed the named collections from PKLIST and left only the * entry.
  • A Java application keeps too many Statement, PreparedStatement or CallableStatement objects open at the same time.

How to find the problem

  1. Read the plan name and program in the message.
  2. Look at the plan's package list with SELECT COLLID, NAME, SEQNO FROM SYSIBM.SYSPACKLIST WHERE PLANNAME = 'PAYPLAN' ORDER BY SEQNO. A COLLID of * means the collection comes from CURRENT PACKAGESET.
  3. Search the program source for SET CURRENT PACKAGESET and check that it runs before the first SQL statement on every path.
  4. For Java, check whether the application closes its ResultSet and Statement objects, and how many it holds open at peak.

How to fix it

  • Set the register before the first SQL statement, for example SET CURRENT PACKAGESET = 'PAYCOLL'.
  • If the program doesn't need to pick its collection, rebind the plan with named collections, such as REBIND PLAN(PAYPLAN) PKLIST(PAYCOLL.*). List every collection the plan needs, because the new list replaces the old one.
  • Keep a named collection entry in PKLIST alongside *.* if some programs set the register and others don't.
  • For Java, close statements as soon as you're done with them. If the application really needs more, run the DB2Binder utility again with a larger -size value so the driver has more packages.

What it looks like

DSNT408I SQLCODE = -812, ERROR:  THE SQL STATEMENT CANNOT BE PROCESSED BECAUSE A BLANK
         COLLECTION-ID WAS FOUND IN THE CURRENT PACKAGESET SPECIAL REGISTER WHILE TRYING
         TO FORM A QUALIFIED PACKAGE NAME FOR PROGRAM PAYCALC.18B2C4F00A1E3D27 USING PLAN
         PAYPLAN
DSNT418I SQLSTATE   = 22508 SQLSTATE RETURN CODE

IBM documentation

IBM documentation: -812. Use the documentation for your installed release.

Report a correction to WND Software.

Questions

How is -812 different from -805?

With -805 Db2 built a package name, searched and found nothing that matched. With -812 it couldn't build the name in the first place, because the collection was blank.

Why would a plan use * as the collection?

So the program can choose its collection at run time with SET CURRENT PACKAGESET. Shops use it to run the same load module against test and production packages.

Does -812 happen on Db2 for LUW?

Plans and package lists are a Db2 for z/OS feature, so this code is seen mostly on z/OS. The JDBC form appears when the driver runs out of its packages on the server.