terça-feira, 5 de novembro de 2013

Estrutura BEGIN/END no PL/SQL

Para atualizações dinâmicas com select no PL/SQL são utilizados estruturas com BEGIN/END. Segue o formato padrão:


  1. -- Created on 05/11/2013 by BOAH
  2. DECLARE
  3.   -- Local variables here
  4.   i INTEGER;
  5. BEGIN
  6.   -- Test statements here
  7.   FOR i IN (SELECT * FROM torder) LOOP
  8.     UPDATE.... WHERE tu_id=i.id
  9.     DELETE....  WHERE tu_id=i.id
  10.     DBMS_OUTPUT.put_line('Atualizado: '|| i.id)--print result
  11.   END LOOP;
  12. END;