DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Mostar Los Resultados De Un Cursor

05.04.2007
| 2383 views |
  • submit to reddit
        Esto muestra los resultados de un cursor en la ventana de pruebas del SQL Developer

Declaración de las variables
c1 varchar2(200);
c2 varchar2(200);
c3 varchar2(200);

Código en sí
fetch v_Return into c1, c2, c3;
loop
  EXIT WHEN v_Return%NOTFOUND;
  DBMS_OUTPUT.PUT_LINE(c1||', '||c2||', '||c3);
  fetch v_Return into c1, c2, c3;
end loop;
close v_Return;

Ejemplo del código completo:
DECLARE
  PVCOD_DESPACHO NUMBER;
  PVCOD_IDIOMA VARCHAR2(200);
  v_Return PG_SGIE_Types.cursor_type;
  c1 varchar2(200);
  c2 varchar2(200);
  c3 varchar2(200);
BEGIN
  PVCOD_DESPACHO := 2792;
  PVCOD_IDIOMA := '1';

  v_Return := FU_LISTAENVIOSDESPACHO(
    PVCOD_DESPACHO => PVCOD_DESPACHO,
    PVCOD_IDIOMA => PVCOD_IDIOMA
  );
  -- Modify the code to output the variable
  --DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
  
  fetch v_Return into c1, c2, c3;
  loop
    EXIT WHEN v_Return%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(c1||', '||c2||', '||c3);
    fetch v_Return into c1, c2, c3;
  end loop;
  close v_Return;
END;