DB2 – How to Grant Permissions to Replace a Function

db2functionspermissions

I am getting the following error message (when trying to enable NOSQL in DB2 10.5, although I don't think that's really the issue):

Error code: -551 DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501,
SQLERRMC=DB2ADMIN;REPLACE FUNCTION; SYSTOOLS.JSON_VAL2, DRIVER=4.17.29

An error occurred during database object creation, rolling back

The DB2ADMIN user already has the following permissions:

grant DBADM, SECADM, ACCESSCTRL, DATAACCESS ON DATABASE TO USER db2admin

I cannot find the GRANT command that I need to use to enable DB2ADMIN to replace the function. Sorry, I'm not a DBA, so I just need the exact command I'd need to enter.

Best Answer

Apparently, whatever you are doing tries to CREATE OR REPLACE the function SYSTOOLS.JSON_VAL2. To replace any object the ID performing the operation must be the owner of that object, that is, the same ID that issued the very first CREATE statement.

You have several options:

  1. Use the TRANSFER OWNERSHIP statement to change the function owner. SECADM can do that.
  2. Determine the current owner (SELECT OWNER FROM SYSCAT.ROUTINES WHERE ROUTINENAME = 'JSON_VAL2' AND ROUTINESCHEMA = 'SYSTOOLS') and perform your task while logged in as that user.
  3. Drop the object explicitly, for which DBADM is sufficient, before performing your task.