DB2 indirect privileges for Stored Procedures

I recently updated a Datastage job to use a direct UPDATE query instead of calling a Stored Procedure(SP) through the job which had the UPDATE query.

The result - The job failed with the error that the 'userid' did not have UPDATE privilege on the table.

I was using the same userid to execute the SP as well.

It took me sometime to understand the reason for this.

The reason is that DB2 userid needs execute privileges for a SP.
The Execute privilege in turn grants indirect privilege to the userid executing the SP for the SQL statement specified in the procedure.

So, as I had the UPDATE SQL statement in my procedure.
And my userid had execute privilege on the procedure.

It was granted indirect privilege to update the table for the purpose of executing the SP. These are temporary privileges and last only till the SP is executing.

Now, I tried to update the table directly using the same userid.
And I got an UPDATE access error because that user id did not have explicit UPDATE privilege on the table.

So, a point to keep in mind while deploying changes that replace stored procedures with direct SQL statements.

1 Comments

Previous Post Next Post

Contact Form