1

I have a block:

DECLARE
  stmnt VARCHAR2(100);
  rol VARCHAR2(10); --role name
  tab_name VARCHAR2(10); --table name
BEGIN
  rol := '&Role_name';
  stmnt := 'create role ' || rol;
  EXECUTE IMMEDIATE stmnt;
  stmnt := 'grant :p on ' || '&tab_name' || ' to ' || rol;
  EXECUTE IMMEDIATE stmnt using '&Privilege';
END;

when I execute this block, after enetering the privilege SELECT, Oracle gives me an error that missing or invalid privilege ORA-00990: missing or invalid privilege

Why it doesn't bind variable?

1 Answer 1

2

You cannot bind Oracle names, only data values. Do this instead:

DECLARE
  stmnt VARCHAR2(100);
  rol VARCHAR2(10); --role name
  tab_name VARCHAR2(10); --table name
BEGIN
  rol := '&Role_name';
  stmnt := 'create role ' || rol;
  EXECUTE IMMEDIATE stmnt;
  stmnt := 'grant &Privilege. on &tab_name. to ' || rol;
  EXECUTE IMMEDIATE stmnt;
END;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.