Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, lh.
Asked: May 31, 2017 - 2:39 pm UTC
Last updated: June 01, 2017 - 10:31 am UTC
Version: 12.1.0.2
Viewed 10K+ times! This question is
create role r; grant r to chris; create user u identified by u; alter user chris grant connect through u; conn hr/hr grant select on employees to r; conn u[chris]/u select count(*) from hr.employees; COUNT(*) 107 conn chris/chris select count(*) from hr.employees; COUNT(*) 107 create or replace procedure p is begin for emps in ( select * from hr.employees where employee_id > 200 ) loop dbms_output.put_line('EMP ID: ' || emps.employee_id); end loop; end p; / sho err LINE/COL ERROR -------- ----------------------------------------------------------------- 4/5 PL/SQL: SQL Statement ignored 4/22 PL/SQL: ORA-00942: table or view does not exist 6/5 PL/SQL: Statement ignored 6/40 PLS-00364: loop index variable 'EMPS' use is invalid conn hr/hr grant select on employees to chris; conn chris/chris create or replace procedure p is begin for emps in ( select * from hr.employees where employee_id > 200 ) loop dbms_output.put_line('EMP ID: ' || emps.employee_id); end loop; end p; / Procedure P compiled conn u[chris]/u exec p; EMP ID: 201 EMP ID: 202 EMP ID: 203 EMP ID: 204 EMP ID: 205 EMP ID: 206
A reader, May 31, 2017 - 6:49 pm UTC
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library