UTL_File-read entire file

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
  

Poston Tue, 23 May 2006 9:06 am

Is there any function that returns the contents of a text file? something like Read to End? Without having to use the ReadLine.


Thank you!

[] 's
MuLtAnI
Location: Videira - SC


Poston Mon, 05 Jun 2006 12:43 pm

Eae do it!
Dude, I think you can use the DBMS_LOB functions to read files direct text p/a CLOB field, for example.

You want to avoid to read line by line, is it?
dr_gori
Location: Portland, OR USA

Thomas F. G

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

Poston Mon, 12 Jun 2006 11:43 am

This aí manow .... well that same.

Code: Select all

INSERT INTO ALL_DIRECTORIES (DIRECTORY_PATH, DIRECTORY_NAME) VALUES ('TEU_PATH', 'TEU_ATALHO');



CREATE TABLE TEST_CLOB
(
  ID         NUMBER(15),
  FILE_NAME  VARCHAR2(1000 BYTE),
  ARQUIVO    CLOB,
  TIMESTAMP  DATE
);



-- arq : Nome do arquivo
-- dir : Nome da ponte criada na tabela ALL_DIRECTORIES
FUNCTION FLEARQUIVO( arq IN varchar2, dir IN varchar2 )
  RETURN clob IS
BEGIN
DECLARE
    arquivo BFILE;

    dest_clob   CLOB;
    dst_offset  number := 1 ;
    src_offset  number := 1 ;
    warning     number;
   
    BEGIN
   
        arquivo := BFILENAME( dir, arq );
       
        INSERT INTO test_clob(id, file_name, arquivo, timestamp)
        VALUES(1001, arq, empty_clob(), sysdate)
        RETURNING arquivo INTO dest_clob;
       
        DBMS_LOB.OPEN(arquivo, DBMS_LOB.LOB_READONLY);
       
        DBMS_LOB.LoadFromFile(
          DEST_LOB => dest_clob
        , SRC_LOB  => arquivo
        , AMOUNT   => DBMS_LOB.GETLENGTH( arquivo ) );
       
        DBMS_LOB.CLOSE( arquivo );
       
        commit;

        RETURN dest_clob;
    END;
END;

[/code]
MuLtAnI
Location: Videira - SC


Poston Wed, 21 Mar 2007 8:00 pm

Guys, I'm beginner in oracle, I'vê always worked with SQL SERVER 2000. I am not able to read a txt file and insert into a table.
Could someone give me a help?
From already thank you
vsouza
Location: Sao Paulo


  • See also
    Replies
    Views
    Last Post


      Return to PL/SQL

      Who is online

      Users browsing this forum: No registered users and 3 guests