Oracle/PL/SQL/Control

De Wikilibros, la colección de libros de texto de contenido libre.
< Oracle‎ | PL/SQL

Expresiones condicionales[editar]

  ...
  if condicion then
    -- Instrucciones
    ...
  elsif condicion2 then
    -- Instrucciones
    ...
  else
    -- Instrucciones
    ...
  end if;
  ...
  ...
  case variable
    when valor1 then
      -- Instrucciones
      ...
    when valor2 then
      -- Instrucciones
      ...
    when valor3 then
      -- Instrucciones
      ...
    else
     -- Instrucciones
    ...
  end case;
  ...

Ciclos[editar]

  ...
  while condicion loop
    -- Instrucciones
    ...
  end loop;
  ...
  ...
  for v_entero in inicio .. fin loop
    -- Instrucciones
    ...
  end loop;
  ...

La variable v_entero se declara automáticamente y tiene validez únicamente dentro del ciclo FOR.

  ...
  loop
    -- Instrucciones
    ...
    exit when condicion;
    ...
    -- Instrucciones
    ...
  end loop;
  ...