Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:51:19+00:00 2026-05-24T22:51:19+00:00

I have a column in my oracle table with CLOB datatype. How do I

  • 0

I have a column in my oracle table with CLOB datatype.
How do I store .txt file in this column and how can I retrieve the same file?

Below is the table definition

fileID  Number
logFile CLOB

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:51:20+00:00Added an answer on May 24, 2026 at 10:51 pm

    Loading a file into a CLOB in PL/SQL is pretty easy– you just need to use the DBMS_LOB.LoadCLOBFromFile procedure

    CREATE DIRECTORY file_dir
        AS <<path on database server file system>>;
    
    GRANT read, write
       ON file_dir
       TO your_user_name;
    
    DECLARE
      l_src_file bfile := BFileName( 'FILE_DIR', <<name of file>> );
      l_dest_lob clob;
    
      l_dest_offset  integer := 1;
      l_src_offset   integer := 1;
      l_lang_context number := dbms_lob.default_lang_ctx;
      l_warning      number;
    BEGIN
      dbms_lob.open( l_src_file, dbms_lob.lob_readonly );
    
      INSERT INTO some_table( fileID, logFile )
        VALUES( fileIDSeq.nextval, empty_clob() )
        RETURNING logFile 
             INTO l_dest_lob;
    
      dbms_lob.LoadCLOBFromFile( 
                  dest_lob     => l_dest_lob,
                  src_bfile    => l_src_file,
                  amount       => dbms_lob.getLength( l_src_file ),
                  dest_offset  => l_dest_offset,
                  src_offset   => l_src_offset,
                  bfile_csid   => dbms_lob.default_csid,
                  lang_context => l_lang_context,
                  warning      => l_warning );
    
      dbms_lob.close( l_src_file );
    END;
    /
    

    Writing the file from the CLOB to the file system again is a bit more involved. I would use something like Tom Kyte’s clob_to_file procedure

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Oracle table which is used to store application settings. This is
I have an oracle table with a column from type SYS.XMLTYPE and a storage
we have a table in an Oracle Database which contains a column with the
We have a Oracle 9i database and OrderDetails table which has a column to
I have column named summary (tinytext, utf8_turkish_ci). I know it can store 255 byte
I have a column in an Oracle DB table that is of type TIMESTAMP(6)
I have a large (multi-GB) data file exported from an Oracle table. I want
I have an Oracle table with data that looks like this: ID BATCH STATUS
I have created an Oracle table with an indexed varchar2 column, called 'ID'. A
I have a table in Oracle where column SC_CUR_CODE is CHAR(3) When I do:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.