Cycle or something similar in PL/SQL Quite often it is necessary to do some repetetive operations / few line queries against set of objects. Let's say you have a list of accounts to unlock via 

alter user %username% account unlock


and instead of typing the same line multiple times for each user I believe some cycle construction can be used but don't know how to write it in PL/SQL. Can somebody advice on this?
set serveroutput on size unlimited
for i in (select 'alter user '||username||' account unlock' cmd
            from dba_users
           where account_status = 'LOCKED'
          )
loop
   dbms_output.put_line (i.cmd);
 --  execute immediate i.cmd;
end loop;
end;
/


This works. Be careful, I have seen ppl doing similar things without testing, effectively destroying databases, especially when using patterns and manipulating database objects with the results. If the output is OK, activate the execute immediate.