Oracle 11g XE - Using a stored procedure to grant privileges to a table I need to write a stored procedure that will grant certain privileges over a table to a user.

However it appears that GRANT cannot be used within a Stored Procedure.

My Curent code is as follows:

CREATE OR REPLACE 
PROCEDURE "setUserPermissions" (u  VARCHAR2, l  INTEGER, tbl VARCHAR2)
AS
BEGIN
    DELETE FROM "userLvl" WHERE "user" = u;
    INSERT INTO "userLvl" VALUES(u,l);
    IF l&gt;0 AND l&lt;6 THEN
        GRANT SELECT ON tbl TO u
        IF l&gt;1 THEN
            GRANT UPDATE ON tbl TO u
        END IF;
        IF l&gt;2 THEN
             GRANT DELETE ON tbl TO u
        END IF;
    END IF;
END;
GRANT is a DDL statement. You can not run DDL statements directly in PL/SQL, but you can use execute immediate:

CREATE OR REPLACE 
PROCEDURE "setUserPermissions" (u  VARCHAR2, l  INTEGER, tbl VARCHAR2)
AS
BEGIN
    DELETE FROM "userLvl" WHERE "user" = u;
    INSERT INTO "userLvl" VALUES(u,l);
    IF l&gt;0 AND l&lt;6 THEN
        execute immediate 'GRANT SELECT ON ' || tbl || ' TO ' || u;
        ...
    END IF;
END;