plsql - Dynamic Sql, problem with binding -


i have 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' || ' ' || rol;   execute immediate stmnt using '&privilege'; end; 

when execute block, after enetering privilege select, oracle gives me error missing or invalid privilege ora-00990: missing or invalid privilege

why doesn't bind variable?

you cannot bind oracle names, data values. 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. ' || rol;   execute immediate stmnt; end; 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -