Never been to DZone Snippets before?

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

About this user

Koke

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Debug logs in the database

How to log things in the database

Create the table:
   1  
   2  create table TMP_LOG (HORA date, ENTRADA varchar(4000));

Write the things I need to the table:
   1  
   2  INSERT INTO TMP_LOG (HORA, ENTRADA) VALUES(SYSDATE, 
   3    'V_NOM_DESTINATARIO1: '||V_NOM_DESTINATARIO1||', V_DOM_DESTINATARIO1: '||V_DOM_DESTINATARIO1||
   4    ', P_NOM_DESTINATARIO_2: '||P_NOM_DESTINATARIO_2||', P_DOM_DESTINATARIO_2: '||P_DOM_DESTINATARIO_2||
   5    ', B_DESTINATARIO: '||B_DESTINATARIO||
   6    ', V_NOM_DESTINATARIO2: '||V_NOM_DESTINATARIO2||', V_DOM_DESTINATARIO2: '||V_DOM_DESTINATARIO2);
   7  

Consult the things written:
   1  
   2  select * from tmp_log order by hora desc;

Dont forget to drop it at the end:
   1  
   2  drop table TMP_LOG;

Mostar los resultados de un cursor

Esto muestra los resultados de un cursor en la ventana de pruebas del SQL Developer

Declaración de las variables
   1  
   2  c1 varchar2(200);
   3  c2 varchar2(200);
   4  c3 varchar2(200);


Código en sí
   1  
   2  fetch v_Return into c1, c2, c3;
   3  loop
   4    EXIT WHEN v_Return%NOTFOUND;
   5    DBMS_OUTPUT.PUT_LINE(c1||', '||c2||', '||c3);
   6    fetch v_Return into c1, c2, c3;
   7  end loop;
   8  close v_Return;


Ejemplo del código completo:
   1  
   2  DECLARE
   3    PVCOD_DESPACHO NUMBER;
   4    PVCOD_IDIOMA VARCHAR2(200);
   5    v_Return PG_SGIE_Types.cursor_type;
   6    c1 varchar2(200);
   7    c2 varchar2(200);
   8    c3 varchar2(200);
   9  BEGIN
  10    PVCOD_DESPACHO := 2792;
  11    PVCOD_IDIOMA := '1';
  12  
  13    v_Return := FU_LISTAENVIOSDESPACHO(
  14      PVCOD_DESPACHO => PVCOD_DESPACHO,
  15      PVCOD_IDIOMA => PVCOD_IDIOMA
  16    );
  17    -- Modify the code to output the variable
  18    --DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
  19    
  20    fetch v_Return into c1, c2, c3;
  21    loop
  22      EXIT WHEN v_Return%NOTFOUND;
  23      DBMS_OUTPUT.PUT_LINE(c1||', '||c2||', '||c3);
  24      fetch v_Return into c1, c2, c3;
  25    end loop;
  26    close v_Return;
  27  END;
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS