Search code examples
oracle-databasestored-proceduressql-grant

Can GRANT be used inside an Oracle Store Procedure?


When trying to place a GRANT statement in an Oracle 11 stored procedure, it reports that GRANT is an unexpected symbol. Does GRANT need to be prefaced by something, or does Oracle simply disallow running GRANTS inside SPs?


Solution

  • It's a bad idea to use DDL (like GRANT) inside stored procedures.

    You will have to use dynamic SQL (EXECUTE IMMEDIATE) to do this, but, honestly, I don't see why would you want to do this inside a stored proc.