Write Oracle Loop in a Script File

Typically any code I write in Oracle it is most often in a procedure or function in a package. At times a stand alone procedure.

The coding performed in an Oracle Procedure can be done in a script file but since I do not do that often I created this post for a copy-paste sample that can be run as a script.
--Declare the VARS outside the begin
declare 
ln_count number;

begin -- Start of Coding

for i in (select constraint_name
          from all_constraints
          where constraint_type = 'R'
          and owner = 'MDSYS'
          and status = 'ENABLED') 
  LOOP
    
  dbms_output.put_line('constraint_name' || i.constraint_name);
  
end loop;

end; -- End Coding

Here is the DBMS Output from the query code above.

 
Comments are closed