Search code examples
stored-proceduressybasedatabase-permissions

Restrict stored procedure to only perform SELECT operations


Is is possible to restrict a stored proc to only SELECT from a database.

I want a stored proc which only selects data to execute correctly and a stored proc with UPDATE, CREATE, DELETE operations to return an error indicating insufficient permissions.

I am using Sybase 12.5


Solution

  • I think you're looking at the problem the wrong way. Essentially, once you give a user execute permission to a store procedure, they can execute that store procedure no matter what it does.

    I think what you want to do is assign a "read-only" client role to your database and grant SELECT permissions as well as the execute permission on only the stored procedures that read data from the database. Add users to that role instead of granting them SELECT access on the database.