1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
SET SERVEROUTPUT ON FEEDBACK OFF VERIFY OFF
WHENEVER SQLERROR EXIT SQL.SQLCODE
variable l_exit number ;
DECLARE
sorties EXCEPTION;
Cursor c1 is
SELECT USERNAME
FROM DBA_USERS
WHERE ACCOUNT_STATUS='OPEN'
AND (REGEXP_LIKE(USERNAME,'^[a-zA-Z]{1}[a-zA-Z0-9]{3}[0-9]{3}$') or REGEXP_LIKE(USERNAME,'^OPS\$[a-zA-Z]{1}[a-zA-Z0-9]{3}[0-9]{3}$'));
cid c1%rowtype;
BEGIN
:l_exit :=0;
OPEN c1 ;
Loop fetch c1 into cid ;
EXIT WHEN c1%NOTFOUND;
dbms_output.put_line(cid.USERNAME);
End Loop;
CLOSE c1;
EXCEPTION
WHEN SORTIES THEN
:l_exit :=14;
WHEN OTHERS THEN
dbms_output.put_line(chr(10)||'ERROR during Oracle operation');
END;
/ |
Partager