Skip to Main Content
  • Questions
  • how can i insert and read numeric value larger than 1000 digits into blob column in oracle

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Giri.

Asked: February 06, 2025 - 6:59 am UTC

Last updated: February 24, 2025 - 3:24 am UTC

Version: oracle 21c express edition

Viewed 1000+ times

You Asked

how can i insert and read numeric value larger than 1000 digits into blob column in oracle

and Connor said...

BLOBs are just bytes - so you can write as many bytes of raw data as you like, eg

SQL> create table t ( b blob );

Table created.

SQL>
SQL> declare
  2    digits raw(1000) := hextoraw(rpad('FF',1000,'FF'));
  3
  4    l_blob blob;
  5  begin
  6    insert into t values ( empty_blob())
  7    returning b into l_blob;
  8
  9    dbms_lob.writeappend(l_blob,length(digits)/2,digits);
 10    dbms_lob.writeappend(l_blob,length(digits)/2,digits);
 11    dbms_lob.writeappend(l_blob,length(digits)/2,digits);
 12    dbms_lob.writeappend(l_blob,length(digits)/2,digits);
 13  end;
 14  /

PL/SQL procedure successfully completed.

SQL>
SQL> select dbms_lob.getlength(b) from t;

DBMS_LOB.GETLENGTH(B)
---------------------
                 2000


Rating

  (4 ratings)

Comments

Giri K, February 14, 2025 - 10:21 am UTC

Thank You
Connor McDonald
February 17, 2025 - 7:46 am UTC

glad we could help

nice

A reader, February 17, 2025 - 7:49 am UTC

easy understanding
Connor McDonald
February 24, 2025 - 3:24 am UTC

glad we could help

Slope Game

Slope Game, March 17, 2025 - 8:22 am UTC

Great example, Connor! Handling large numeric data in BLOBs is tricky. Encoding the number as a string before storing it might be another approach. It could be viewed as navigating the Slope Game, where obstacles (data limits) require strategic maneuvering (encoding/decoding) to reach the goal (data persistence). Anyone experimented with different encoding methods for optimal storage/retrieval?
https://slopegame.lol

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here