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 8477251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:24:41+00:00 2026-06-10T18:24:41+00:00

Could you tell me, why this function returns as result an empty blob value?

  • 0

Could you tell me, why this function returns as result an empty blob value?
It don’t even close the BFILE type variable after the loop. I can’t imaging where is the problem.

FUNCTION f$bfile_to_blob
  (I_FID_ID IN INTEGER)
  RETURN BLOB IS
   bf            BFILE;
   Amount        INTEGER := 32767;
   Position      integer := 1;
   buffer        RAW(32767);
   bl            LONG RAW := '';

   bb            BLOB;

BEGIN
  select fid_bckp into bf
   from filedoc
  where fid_id = I_FID_ID;

  dbms_lob.open(bf, dbms_lob.lob_readonly);

  DBMS_LOB.CREATETEMPORARY(bb, TRUE, DBMS_LOB.SESSION);
  LOOP
    dbms_lob.read(bf, Amount, Position, buffer);
    dbms_lob.writeappend(bb,amount,buffer);
    Position := Position + Amount;
  END LOOP;

  dbms_lob.close(bf);

  return bb;

END;

I call the function this way

select F$BFILE_TO_BLOB(fid_id) from filedoc where fid_id = 2150;
  • 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-06-10T18:24:43+00:00Added an answer on June 10, 2026 at 6:24 pm

    Your logic is complex, you’re mixing many elements that can produce errors: namely CLOB and BFILE. You should try first to isolate which element in your function leads to this abnormal behaviour.

    I suggest you run a simple function to make sure that your BLOB logic is fine:

    create or replace FUNCTION f$bfile_to_blob
      RETURN BLOB IS
       bb            BLOB;
    BEGIN
      DBMS_LOB.CREATETEMPORARY(bb, TRUE, DBMS_LOB.SESSION);
      bb := hextoraw('FFFFFFFF');
      return bb;
    END;
    
    select rawtohex(dbms_lob.substr(f$bfile_to_blob, 4000, 1)) from dual;
    

    This should produce FFFFFFFF. Now you know that the problem lies with your reading of the BFILE object. We can see in your code that you have a loop withoug an exit condition. Since the program exits, we deduct that your loop exits with an error.

    The documentation explains that the exception is raised by the READ procedure:

    The number of bytes or characters actually read is returned in the amount parameter. If the input offset points past the End of LOB, then amount is set to 0, and a NO_DATA_FOUND exception is raised.

    The exception is raised and the function exits without having return anything.

    As you may know, NO_DATA_FOUND exceptions are not considered errors inside an SQL statement. The error is interpreted as NULL by the SELECT query.

    You should modify your function to catch this error and exit the loop gracefully:

    FUNCTION f$bfile_to_blob(I_FID_ID IN INTEGER)
       RETURN BLOB IS
       bf       BFILE;
       Amount   INTEGER := 32767;
       Position INTEGER := 1;
       buffer   RAW(32767);
       bl       LONG RAW := '';
       bb       BLOB;
    BEGIN
       SELECT fid_bckp
         INTO bf
         FROM filedoc
        WHERE fid_id = I_FID_ID;
       dbms_lob.open(bf, dbms_lob.lob_readonly);
       DBMS_LOB.CREATETEMPORARY(bb, TRUE, DBMS_LOB.SESSION);
    
       LOOP
          BEGIN
             dbms_lob.read(bf, Amount, Position, buffer);
          EXCEPTION 
             WHEN NO_DATA_FOUND THEN
                EXIT;
          END;
          dbms_lob.writeappend(bb, amount, buffer);
          Position := Position + Amount; 
       END LOOP;
    
       dbms_lob.close(bf);
    
       RETURN bb;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could you please tell why the Asc() function returns incorrect result? Dim TestChar =
Could someone tell me if this: $.ajax({ url: 'test.html', success: function(data) { alert(Data Loaded:
Could someone tell me what is wrong with this code please. Public Shared Function
Could someone tell me why this code does not update the data response? It's
could someone tell me if this is the right way to do bidirectional mapping?
Could someone please tell me why this <%= destroy_password_url @user.password_reset_token %> generates http://localhost:3000/api/destroy_password.4G5EoRVYMUAtiIKqOerKsw routes.rb
Could someone please tell me whats wrong with this code because I cannot find
Consider a function that returns a Type* , and so it looks like it
Could somebody tell me a Perl module with a function, that converts digits like
Ok so i was wondering if anyone could tell me where i am going

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.