Problema com Text_IO - arquivo sem quebra de linha

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Responder
esttevan
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 17
Registrado em: Qua, 07 Out 2009 10:11 am
Localização: Nova Hartz - RS

Estou usando TEXT_IO para ler um arquivo xml, concatenando as linhas num clob, convertendo e gravando-o no banco em uma coluna xmltype.

O problema é que estou recebendo arquivo xml sem quebra de linha e está estourando o tamanho de 4000 da variavel usada para pegar a linha (TEXT_IO.GET_LINE(ARQUIVO, LINHA)).

alguém tem alguma dica de como posso ler este arquivo via forms 6i e grava-lo no banco de dados.

Estevan
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Uma idéia é você fazer assim:
Ler o arquivo inteiro num clob, e ir pegando pedaços dele depois como você precisar.

Aqui tem um texto explicando como ler Clob no Forms 6i.
http://talk2gerd.blogspot.com.br/2006/0 ... ms-6i.html

Selecionar tudo

Using CLOB's in Forms 6i
It's not possible to use the new datatype CLOB in Oracle Forms 6i.

So let us invent a workaround !

Assumption: Table EMP in the db has a new column Note_CLOB, A form with the block EMP and all EMP-columns without the CLOB.

Requirement: The CLOB-column from the db should be shown and editable in the form.

First create a textitem "Note_CLOB" in the block EMP:

Item-Properties:
- Data Type CHAR
- Maximum Length 32000
- Database-Item No

Item-Trigger:
- WHEN-VALIDATE-ITEM

:EMP.EMPNO := :EMP.EMPNO;

Block-Trigger:
- POST-QUERY
POQ_EMP;

- PRE-UPDATE
PRU_EMP;

These program units are needed for the form

PROCEDURE POQ_EMP IS
  V_String   VARCHAR2 (1000);
  V_Index    NUMBER := 0;
BEGIN
  LOOP
    V_String := Read_CLOB (:EMP.EMPNO, V_Index);
    IF V_String IS NOT NULL THEN
      :EMP.Note_CLOB := :EMP.Note_CLOB || V_String;
      V_Index := V_Index + 1;
    ELSE
      EXIT;
    END IF;
  END LOOP;
END;

PROCEDURE PRU_EMP IS
  V_String   VARCHAR2 (1000);
  V_Index    NUMBER := 0
BEGIN
  Clear_CLOB (:EMP.EMPNO);
  LOOP
    V_String := Substr (:EMP.Note_CLOB, 1 + V_Index * 1000, 1000);
    IF V_String IS NOT NULL THEN
      Append_CLOB (:EMP.EMPNO, V_String);
      V_Index := V_Index + 1;
    ELSE
      EXIT;
    END IF;
  END LOOP;
END;


This routines are needed in the database


PROCEDURE CLEAR_CLOB (P_EMPNO IN EMP.EMPNO%TYPE) IS
BEGIN
  UPDATE EMP SET Note_CLOB = NULL
   WHERE EMPNO = P_EMPNO;
END;

PROCEDURE APPEND_CLOB (P_EMPNO IN EMP.EMPNO%TYPE, P_STRING IN VARCHAR2) IS
BEGIN
  UPDATE EMP SET Note_CLOB = Note_CLOB || P_String
   WHERE EMPNO = P_EMPNO;
END;

FUNCTION READ_CLOB (P_EMPNO IN EMP.EMPNO%TYPE, P_INDEX IN NUMBER) RETURN VARCHAR2 IS
  V_STRING VARCHAR2 (2000);
BEGIN
  SELECT SUBSTR (Note_CLOB, 1 + P_Index * 1000, 1000)
    INTO V_String
    FROM EMP
   WHERE EMPNO = P_EMPNO;
  RETURN (V_String);
END;

with this technique it is possible to read and write 32K from a CLOB.

try and test it
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 16 visitantes