Campo Clob em Forms 6i

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Responder
marlonpasquali
Rank: DBA Pleno
Rank: DBA Pleno
Mensagens: 248
Registrado em: Sex, 06 Fev 2009 3:02 pm
Localização: ERECHIM - RS

Bom dia pessoal,
preciso de uma ajuda. Tenho que fazer um form que tem um campo na tabela tipo Clob. Isto porque vai ter um texto grande.
Só que não estou conseguindo fazer o form. Fiz o Form pelo assistente e ele criou um campo tipo Extenso. Mas quando insiro a informaçao e salvo, quando vou consultar o registro pelo F8, o campo volta vazio. Não está gravando o conteudo no Clob.
Como faço isso ?

obrigado,
Marlon
victorhugomuniz
Moderador
Moderador
Mensagens: 1396
Registrado em: Sex, 01 Fev 2008 2:06 pm
Localização: Rio de Janeiro - RJ
Contato:
:D

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

Selecionar tudo

:EMP.EMPNO := :EMP.EMPNO;

Block-Trigger:
- POST-QUERY - PRE-UPDATE These program units are needed for the form

Selecionar tudo

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

Selecionar tudo

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
fonte

http://glufke.net/oracle/viewtopic.php?p=5099
http://fdegrelle.over-blog.com/article-2615079.html
marlonpasquali
Rank: DBA Pleno
Rank: DBA Pleno
Mensagens: 248
Registrado em: Sex, 06 Fev 2009 3:02 pm
Localização: ERECHIM - RS

ok. Muito obrigado,

Marlon
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Majestic-12 [Bot] e 9 visitantes