BLOB vs BFILE

Dear Oracle Group,
Our applications are basically Client/Server and/or n-tier typical windows applications. The data is stored in Oracle 9i database on Solaris. Now..., I would like to store photographs and pdf documents in the database. I have read many documents on how to store jpegs and pdfs in Oracle database.
And I understand that I can store it in the database as a BLOB, BFILE or ORDSYS.OrdImage type column. But I have few problems here. My understanding is that, If I use BFILE or ORDSYS.OrdImage datatype, the image will be copied into the database server (Solaris), and we do not want the files to be copied into Solaris as an operating system file.
Please if you have any thoughts and/or samples share with me.
Thanks in advance,
Raja

Here is a C++ example using ORDImage
#include <iostream>
#include <fstream>
#include <occi.h>
#include <unistd.h>
#include <string>
using namespace oracle::occi;
using namespace std;
/* Buffer Size */
#define BUFSIZE 16384;
class occiImage
public:
string username;
string password;
string url;
void insertImageRow (Connection *conn, unsigned int id,
string descrip, string location, string fName)
throw (SQLException)
// Open input file to populate blob
ifstream inFile;
inFile.open(fName.data(), ios::in | ios::binary );
if (!inFile)
cout << fName; cout << " file not found\n";
return;
// Insert row into DB returning ID and blob to be populated
Statement *stmt = conn->createStatement
( "Insert into Photos t values \
(:v1, :v2, :v3, Ordimage.Init(), OrdImage.Init()) returning \
ROWID, t.image.getContent() into :v4, :v5");
stmt->setInt(1, id);
stmt->setString(2, descrip);
stmt->setString(3, location);
stmt->registerOutParam(4, OCCISTRING, 50);
stmt->registerOutParam(5, OCCIBLOB);
stmt->executeUpdate();
string rid = stmt->getString(4);
Blob blob = stmt->getBlob(5);
// Populate interMedia blob from file using stream interface
unsigned int bufsize=BUFSIZE;
char *buffer = new char[bufsize];
Stream *strm = blob.getStream();
while(inFile)
inFile.read((char *)buffer, bufsize);
strm->writeBuffer(buffer,inFile.gcount());
strm->writeLastBuffer(buffer, 0);
blob.closeStream(strm);
inFile.close();
delete[] buffer;
// In the same transaction, Set the image properties and create a thumbnail
stmt->setSQL
("DECLARE \
img ORDIMAGE; \
thumbnail ORDIMAGE; \
BEGIN \
select image, thumb into img, thumbnail from Photos \
where rowid = :v1 for update; \
img.setMimetype(:v2); \
BEGIN \
img.setProperties(); \
img.processCopy('fileFormat=JFIF maxScale=128 128', thumbnail); \
EXCEPTION WHEN OTHERS THEN thumbnail := NULL; \
END; \
update Photos set image=img, thumb=thumbnail where rowid = :v1; \
END;");
stmt->setString(1, rid);
// set default mime type based upon file Extension in
// case of setProperties failure (image/<FILE_EXTENSION>)
stmt->setString(2, "image/" + fName.substr(fName.find_last_of(".") + 1));
stmt->executeUpdate();
conn->commit();
conn->terminateStatement (stmt);
cout << "Populating and initializing the Image - Success" << endl;
return;
void writeThumbnailFile (Connection *conn, unsigned int id,
string fprefix)
throw (SQLException)
cout << "createStatement\n";
Statement *stmt = conn->createStatement
( "Select t.thumb.getContent(), t.thumb.getMimetype() from Photos t \
where t.id= :v1");
stmt->setInt(1, id);
ResultSet *rset = stmt->executeQuery ();
if (rset->next ())
Blob blob = rset->getBlob (1);
string mimeType = rset->getString(2);
string fName = fprefix + "." +
mimeType.substr(mimeType.find_last_of("/") + 1);
cout << "Output file name is " << fName << endl;
ofstream outFile;
outFile.open(fName.data() , ios::out | ios::binary);
if (!outFile)
cout << fName; cout << " file could not be created\n";
conn->terminateStatement (stmt);
return;
unsigned int bufsize=BUFSIZE;
char *buffer = new char[bufsize];
Stream *inStream = blob.getStream (1,0);
while (1)
int bytesRead = inStream->readBuffer(buffer, bufsize);
if (bytesRead < 0) break;
outFile.write(buffer, bytesRead);
blob.closeStream(inStream);
outFile.close();
delete[] buffer;
conn->commit();
conn->terminateStatement (stmt);
return;
occiImage ()
* default values of username & password
username = "scott";
password = "tiger";
url = "";
void setUsername (string u)
username = u;
void setPassword (string p)
password = p;
void setUrl (string u)
url = u;
void runImageSample ()
throw (SQLException)
Environment *env = Environment::createEnvironment (
Environment::DEFAULT);
Connection *conn = env->createConnection (username, password, url);
cout << "Start runImageSample\n";
insertImageRow (conn, 1, "picture", "somewhere", "image.dat");
writeThumbnailFile(conn, 1, "thumbnail");
env->terminateConnection (conn);
Environment::terminateEnvironment (env);
};//end of class occiImage
int main (void)
try
occiImage *i = new occiImage ();
i->setUsername ("scott");
i->setPassword ("tiger");
i->runImageSample ();
delete(i);
catch (exception &e)
cout << e.what();
}

Similar Messages

  • Blobs and bfiles

    i hav tried many examples of blobs and bfiles but without any success.
    when i used bfiles it creates a directory but i cant see the directory in the drive.
    even with blobs i have never been able to insert rows into it. i cannot even use Select * from tablename if it has a blob column
    can somebody help

    The directory is created in the DB and not on your disk
    You should be able to see it with a "select * from all_directories" ( if you have enough
    permisson )
    Then when you try to select all the data of the table that contains BLOB, you can't obtain the result. But you can do :
    select DBMS_LOB.GETLENGTH(name of the column that contains BFILE or BLOBS) from tabel
    You will obtain the size of the file inserted ...
    To see the images, you have to use Dev2k for instance.
    null

  • Using BLOB or BFILE datatype

    Hi, anyone used BLOB or BFILE before?
    Currently I am thinking of using BLOB or BFILE to store documents (.doc, .pdf, .ppt, .rft, .csv). Can decide yet on which to use. Anyone got any recommendation on which to use?
    1. Any performace issue when using blob after i had stored it in a different tablespace?
    2. Will it take much longer time for export if to use blob.
    3. As for BFILE will it get corrupted if the physical files is delete or been moved to some other location?
    Thanks you in advance, you comments/advice is greatly appreciated..
    Regards,
    lbinsoon

    1. If the blob is in a different tablespace from the row it resides in, that is not a performance impact.
    2. Yes. And how much depends on how much blob data you have. This is because BFILE data is not exported, only the pointers are. So, if you have blob data, it IS exported, making for longer running exports.
    3. Yes. Well, not corrupted, but, of course, you won't be able to access the file. You must update it to point to the new name or location, which can be done with a simple update stmt thus:
    update bf set b = bfilename('d:\tmp','some_binary_file.dat')
    assuming column b is of type BFILE.
    Tom Best

  • BLOB,NCLOB,BFILE doubts

    Sir
    Probably its look a basic question to this forum.And I am also accepting I know very little about SQL.I am basically preparing for exam 1z0-051.and want to clear a doubt.
    How to Insert a BLOB,CLOB,NCLOB,BFILE field?
    a create statement is enough to create a table but how do i inser values for this field?do i need any third party software to do so?
    Our OAEC teacher is claiming insertion and updation is not done by sql / sql*plus or by any sql commands.its all left to the third party software.
    What I believe (I know its not important for this group but still I am explaining it to clear my doubts) :
    May be a third party software is required to convert it into byte stream but actual insertion is done by SQL.
    thanks in advance

    Hm, see:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#sthref3873
    Our OAEC teacher is claiming insertion and updation is not done by sql / sql*plus or by any sql commands.its all left to the third party software.Has he tried:
    MHO%xe> create table t (
      2  ablob BLOB
      3  ,aclob CLOB
      4  ,anclob NCLOB
      5  ,abfile BFILE
      6  );
    Tabel is aangemaakt.
    Verstreken: 00:00:09.79
    MHO%xe> insert into t select 'A', 'B', 'C', 'D' from dual;
    insert into t select 'A', 'B', 'C', 'D' from dual
    FOUT in regel 1:
    .ORA-00932: inconsistent datatypes: expected FILE got CHAR
    Verstreken: 00:00:00.10
    MHO%xe> insert into t select 'A', 'B', 'C', null  from dual;
    1 rij is aangemaakt.

  • BLOB OF BFILE

    Hi,
    I have to insert in a database a lot of images, documents, audio and video files, (2G/mounth) My database should keep this entire files and any time to have the possibility to recover the information in case of disaster. If I will use bfile filed and I will keep this files on a file server I will not be sure if in case of failure of file server I can restore all document , which are vital for company.
    What is most efficient mode to keep this file in blob field or in a bfile.
    Thk,
    Catalin

    One of the most important reasons that one would choose to store multimedia in the database is to be able to manage this content safely and efficiently. Having multimedia in the database allows you to use database itegrity techniques to keep your data safe and consistent. If you choose to use BFILE storage, you will NOT have these advantages. You will have to back up the database, and the filesystem(s) where the multimedia is stored, and devise a way to keep this data consistent. You will not be able to rely upon the database backup entirely, you would need filesystem backups to be coordinated with database backups.
    I would suggest that you store the multimedia in BLOBs within the database.
    From the LOB application developer's guide:
    * External (BFILE) LOBs do not participate in transactions. Any support for integrity and durability must be provided by the underlying file system as governed by the operating system.

  • Blob or Bfile?

    Hi,
    I need to store some pdf file (about 50kb each) into oracle 8.1.7. Which datatype (BLOB, BFILE) is better? As I understand BLOB is inside database, BFILE is outside database. And the number of records are about 6000 in about 3 years but all are critical data.
    After I store the PDF file, I also need to retrive it back probally once or two times.
    Thanks.
    David

    As i found Bfile is better cause all the images are stored outside the database. if there are no of images are to store the use bfile.
    In other case Blob is also fine but in that case use bigger block size tablespace for storing the images.
    Regards
    Singh

  • Conversion From BLOB to Bfile

    Hi,
    I have table with a blob column. I need to extract the blob to a file on file system.
    At the moment the DB is a 9.0, but we are about to migrate to 10.1
    Does anybody know how to perform this action (possibly for both versions) ?
    Thank in advance
    Fabio

    Hi,
    if you have access to Oracle Metalink, then start here:
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=150104.1
    Tomas

  • BLOB e BFILE

    I've a problem to manage file .doc or .xls with PL/SQL to display their contents or to read a part of them. I put the locator in my BFILE field but after I don't display it. Are there any samples code?
    Thanks Lidia
    P.S. Now I work with 8i version.

    Ops!! It's my error, better: I wrote a PL/SQL procedure to test BFILE. I update my field BFILE in my table many times, same times I move the files in other directories, but it's strange that after update and commit table I execute my procedure (that use DBMS_LOB packages) to display my .doc file and I see old file that I changed.
    to update bfile field is it enough update command?

  • Performance impact in Oracle 8i - BLOB vs BFILE

    Hi Guys,
    We are evaluting intermedia to store multimedia objects.
    Does any know if storing and retreiving documents in Oracle database has impact on standard data stored in the database?
    Is it worth having a seperate database instance for storing tables with intermedia objects?
    Pal

    Part 2:
    Example 1: Let us estimate the storage requirements for a data set consisting of 500 video clips comprising a total size of 250MB (average size 512K bytes). Assume a LOB chunk size of 32768 bytes. Our model estimates that we need (8000 * 32) bytes or 250 k bytes for the index and 266 MB to hold the media data. Since the original media size is 250 MB, this represents about a 6.5% storage overhead for storing the media data in the database. The following table definition could be used to store this amount of data.
    create table video_items
    video_id number ,
    video_clip ordsys.ordvideo
    -- storage parameters for table in general
    tablespace video1 storage (initial 1M next 10M )
    -- special storage parameters for the video content
    lob (video_clip.source.localdata) store as
    (tablespace video2 storage (initial 260k next 270M )
    disable storage in row nocache nologging chunk 32768);
    Example 2: Let us estimate the storage requirements for a data set consisting of 5000 images with an average size of 56K bytes. The total amount of media data is 274 MB. Since the average image size is smaller, it is more space efficient to choose a smaller chunk size, say 8K, to store the data in the lob. Our model estimates that we will need about 313 MB to store the data and a little over 1 MB to store the index. In this case the 40 MB of storage required beyond the raw media content size represents a 15% overhead.
    Estimating retrieval costs
    Performance testing has shown that Oracle can achieve equivalent and even higher throughput performance for media content retrieval than a file system. The test was configured to retrieve media data from a server system to a requesting client system. In the database case, simple C client programs used OCI with LOB read callbacks to retrieve the data from the database. For the file system case, the client program used the standard C library functions to read data from the file system. Note that in this client server configuration, files are served remotely by the file server system. In essence, we are comparing distributed file system performance with Oracle database and SQLNet performance. These tests were performed on Windows NT 4 SP5.
    Although Oracle achieved higher absolute performance, the relative CPU cost per unit of throughput ranged from 1.7 to 3 times the file system cost. (For these tests, database performance ranged from 3.4 million to 9 million bytes/sec while file system performance ranged from 2.6 million bytes/sec to 7 million bytes/sec as the number of clients ranged from 1 to 5) One reason for the very high relative CPU cost at the higher end of performance is that as the 100 Mbs network approaches saturation, the system used more CPU to achieve the next increment of throughput. If we restrict ourselves to not exceeding 70% of network utilization, then the database can use up to 2.5 times as much CPU as the file system per unit of throughput.
    NOTE WELL: The extra CPU cost factors pertain only to media retrieval aspect of the workload. They do not apply to the entire system workload. See example.
    Example: A file based media asset system uses 10% of a single CPU simply to serve media data to requesting clients. If we were to store the media in an Oracle database and retrieve content from the database then we could expect to need 20-25% of a single CPU to serve content at the same throughput rate.

  • Help abt store and delete images as blob & bfile using Visual C++

    Hi
    Does anyone knows if there is code for visual c++
    to store and delete images as blob or bfile?
    thanx

    The documentation states there are examples in the oracle database distribution: <ORACLE_HOME>/rdbms/demo/cdemolb.c <ORACLE_HOME>/rdbms/demo/cdemolb2.c <ORACLE_HOME>/rdbms/demo/cdemolbs.c
    These examples are in c, but can be used in c++
    http://otn.oracle.com/doc/server.815/a67846/app_exam.htm#430289

  • BFileSample:  Error while selecting BFILE Locator java.sql.SQLException: ORA-22288:

    Hello, i have compiled and executed the BFileSample java standalone successfully. I am wondering how to use this in a production environment where there may be hundreds of image files stored categorically over a period of years? is it possible to use the BFILE_TABLE in conjunction w/ other tables e.g. use the BFILE_TABLE as fk to some table to query the oracle instance for select image files based on say some category: time, location and other relations? i have tried select * on BFILE_TABLE but i get the following errors:
    SQL> select BFILE_COLUMN from BFILE_TABLE;
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    Is the BFILE_TABLE usefull in anyway outside of the current implementation? thanx, david.

    Hi David,
    BFILE's are also called external LOB's, since data is stored in OS files outside the database and use reference semantics.
    Apart from conventional secondary storage devices such as hard disks, BFILEs may also be located on tertiary block storage devices such as CD-ROMs, PhotoCDs and DVDs.
    A table having BFILE column can be used like any other table, you can reference any column and have fk relationships. The only disadvantage of BFILE's is that backup doesn't happen automatically (since reference is only stored), the OS has to take care of backups of BFILE data.
    LOB's(BLOB, CLOB, BFILE) cannot be viewed in SQL Plus using selects, you can either get length or any associated attributes of these datatypes.
    example:
    select dbms_lob.getlength( BFILE_COLUMN) from bfile_table;
    I would suggest BFILE when you don't want to stress your tablespace(CLOB and BLOB sit on tablespace) and also when data need not be replicated .i.e if you copy a BFILE record, data is not copied, only the reference is copied(both reference will point to same file), but in case of CLOB and BLOB complete data is duplicated.
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96591/adl12bfl.htm#99013
    Hope this helps.
    Elango.

  • PDF's storing in Compressed BLOB Securefile doesn't save space

    Hello 1 have a Test-table in 10G with 1 LOB-segment of 1700 Mb , 1743 records with PDF's
    In 11G 11.1.0.7 i create a table with SCEUREFILE in ASSM tablespace, the table is partitioned.
    When 1 insert the 1743 records wioth PDF's the total segmentsize is even 1900 MB...???
    Why are my PDF's not more compressed?
    CREATE TABLE SNL_SCAN.DOCUMENTEN_LGE
    OWNER VARCHAR2(50 BYTE),
    COMPANY VARCHAR2(50 BYTE),
    SCAN_ID VARCHAR2(50 BYTE) NOT NULL,
    DOCUMENT BLOB,
    FILENAME VARCHAR2(255 BYTE),
    CONTENT_TYPE VARCHAR2(50 BYTE),
    ORDER_DATE DATE,
    SCAN_DATE DATE,
    STATUS VARCHAR2(1 BYTE),
    CUSTOM_01 VARCHAR2(50 BYTE),
    CUSTOM_02 VARCHAR2(50 BYTE),
    CUSTOM_03 VARCHAR2(50 BYTE),
    CUSTOM_04 VARCHAR2(50 BYTE),
    CUSTOM_05 VARCHAR2(50 BYTE),
    CUSTOM_06 VARCHAR2(50 BYTE),
    OWNER_ID NUMBER(9) NOT NULL,
    SCAN_PLACE_DATE DATE DEFAULT sysdate
    TABLESPACE SCAN_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    PARTITION BY RANGE (SCAN_DATE)
    INTERVAL( NUMTOYMINTERVAL(1,'MONTH'))
    PARTITION DOCUMENTEN_LGE_200605 VALUES LESS THAN (TO_DATE(' 2006-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    COMPRESS FOR ALL OPERATIONS
    TABLESPACE SCAN_DATA
    LOB (DOCUMENT) STORE AS SECUREFILE
    ( TABLESPACE SCAN_DATA
    ENABLE STORAGE IN ROW
    CHUNK 8192
    RETENTION
    NOCACHE
    COMPRESS HIGH
    STORAGE (
    INITIAL 64K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    FREELISTS 1
    FREELIST GROUPS 1
    BUFFER_POOL DEFAULT
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    COMPRESS FOR ALL OPERATIONS
    NOCACHE
    NOPARALLEL
    MONITORING
    ENABLE ROW MOVEMENT;

    Hello Sushil,
    i have used the securefileperformancepaper.pdf as test doument, i also simplefied the test:
    1.
    Inserted the pdf into a table:
    declare
    Dest_loc BLOB;
    Src_loc BFILE;
    BEGIN
    INSERT INTO SNL_SCAN.DOCUMENTEN (scan_id,owner_id, document) VALUES (1,1, EMPTY_BLOB())
    RETURNING document INTO Dest_loc;
    Src_loc := BFILENAME ('DIR_TESTCASE', 'sec.pdf');
    DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
    DBMS_LOB.FILECLOSE (Src_loc);
    INSERT INTO SNL_SCAN.DOCUMENTEN (scan_id,owner_id, document) VALUES (2,2, EMPTY_BLOB())
    RETURNING document INTO Dest_loc;
    Src_loc := BFILENAME ('DIR_TESTCASE', 'sec.pdf');
    DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
    DBMS_LOB.FILECLOSE (Src_loc);
    END;
    2.
    created table
    CREATE TABLE NOCOMP ( a BLOB)
    LOB(a) STORE AS SECUREFILE
    ( CACHE ) ;
    inserted 10 documents
    10x-----
    insert into nocomp
    (select document from snl_scan.documenten where scan_id= '1');
    commit;
    the lobsegment is now 4,19 MB
    3.
    inserted another 100 rows
    the lobsegment is now 42,2 MB
    4.
    Created table with compressed LOB
    CREATE TABLE COMP ( a BLOB)
    LOB(a) STORE AS SECUREFILE
    ( COMPRESS HIGH
    CACHE ) ;
    inserted 10 documents
    10x-----
    insert into comp
    (select document from snl_scan.documenten where scan_id= '1');
    commit;
    the lobsegment is now 4,25 MB
    inserted another 100 rows
    the lobsegment is now 42,2 MB
    5.
    so there is no compression.
    6.
    Created table with compressed LOB an DEDUPLICTION
    CREATE TABLE COMP_DEDUP ( a BLOB)
    LOB(a) STORE AS SECUREFILE
    ( COMPRESS HIGH
    DEDUPLICATE
    CACHE ) ;
    7,
    inserted 10 documents
    10x-----
    insert into comp
    (select document from snl_scan.documenten where scan_id= '1');
    commit;
    the lobsegment is now 1,25 MB
    inserted another 100 rows
    the lobsegment is now 1,25 MB
    Deduplication is working, compression with the oracle pdf isn't saving any space......
    8.
    VIEW DBA_LOBS
    TABLE_NAME     COL     SEGMENT_NAME CACHE LOGGING ENCRYPT     COMPRESSION DEDUPLICATION     IN_ROW     FORMAT     PARTITIONED     SECUREFILE
    COMP_DEDUP     A     SYS_LOB0000107972C00001$$     YES     YES     NO     HIGH     LOB     YES N/A NO     YES
    COMP      A     SYS_LOB0000107981C00001$$     YES     YES     NO     HIGH     NO     YES N/A NO     YES
    NOCOMP      A     SYS_LOB0000107984C00001$$     YES     YES     NO     NO     NO     YES      N/A NO     YES
    Hope this helps.
    Rob Tousain
    00 31 6 28660287

  • APEX BFILE

    I have to store graphical documents in an Oracle Database using Apex. I have designed an application based on the Sample Application for Customers, Product, Orders Page 3 and 6 using apex_util.get_blob_file_src and a File Browse Item to store the document in a BLOB field. That works perfectly.
    Now I had to change the application to store the BLOB content in a file and set a pointer in a BFILE column leaving the BLOB column empty. Therefore I wrote a view converting BFILE to BLOB and some instead of triggers to convert BLOB to BFILE.
    Then I rewrote my Apex pages using the view instead of the table. It doesn’t work. I noticed that when using the table Apex is first executing an INSERT leaving the BLOB empty and after that an UPDATE to fill the BLOB column when creating a new record. When using the view instead of the table the INSERT is executed but not the UPDATE.
    So I wanted to write a page process to update the table manually. But I found that there was no entry in the view APEX_APPLICATION_FILES generated by Apex. So I have no chance to obtain the BLOB value and use it to update my table.
    What can I do to have the BLOB content written by Apex to the table the view APEX_APPLICATION_FILES is selecting from?

    Hi
    WWV_FLOW_FILES uses APEX security mechanisms - so you cannot see any entry when selecting it
    from e.g. SQL*Plus. If you want to check the entries you need to use SQL Workshop.
    If you create a File Browse Item named P1_FILE you can select the BLOB content with
    declare
    v_lob blob;
    begin
    -- get uploaded content
    select CLOB_CONTENT into v_lob from wwv_flow_files where name = :P1_FILE;
    -- insert into own table
    insert into ...
    -- remove from WWV_FLOW_FILES after copying
    delete from wwv_flow_files where name = :P1_FILE;
    end;
    Note that you cannot insert into a BFILE - your target table column must be of the type BLOB
    Regards
    -Carsten

  • Reg-inserting Values to blob column

    Dear Gurus,
    I need clarification for this code.
    create table demo
    ( id        int primary key,
      theBlob    blob
    create or replace directory my_files as '/export/home/tkyte/public_html';
    declare
        l_blob    blob;
        l_bfile    bfile;
    begin
        insert into demo values ( 1, empty_blob() )
        returning theBlob into l_blob;
        l_bfile := bfilename( 'MY_FILES', 'aria.gif' );
        dbms_lob.fileopen( l_bfile );
        dbms_lob.loadfromfile( l_blob, l_bfile,
                                   dbms_lob.getlength( l_bfile ) );
        dbms_lob.fileclose( l_bfile );
    end;
    / 1) What value the l_blob variable will contain after returning clause
    2)If we load value to l_blob variable using dbms_lob.loadfromfile() procedure,will it automatically load that value in the demo table.
    Cheers,
    Jey

    The BLOB is store inside the database if that's what you mean.
    For outside storage (ie in the OS file system), you need a BFILE.
    Some precisions about the internal storage though.
    Each LOB is associated with a segment of type "LOBSEGMENT" that resides in the same tablespace as the table (at creation time).
    - LOB data can be stored "in-line" if its size is less than 4000 bytes and if the clause ENABLE STORAGE IN ROW is specified when creating table (that's the default).
    - Otherwise, data is stored in the lob segment ("out-of-line" storage).

  • Insert Image to BLOB column

    Hi,
    How can i insert a image/largefile into table (having BLOB column) from sql plus?
    Thanks

    Hi!
    Do this with PL/SQL.
    CREATE TABLE image_tbl
      filename VARCHAR2(4000),
      image   BLOB
    DECLARE
          v_blob       BLOB;
          v_srcfile    BFILE;
    BEGIN
          DBMS_LOB.CreateTemporary(v_blob, TRUE);
          DBMS_LOB.Open(v_blob, dbms_lob.Lob_ReadWrite);
          v_srcfile := Bfilename('IMAGE_DIR', 'image.gif');
          DBMS_LOB.FileOpen (v_srcfile, dbms_lob.File_ReadOnly);
          DBMS_LOB.LoadFromFile(v_blob, v_srcfile, DBMS_LOB.GetLength(v_srcfile));
          INSERT INTO image_tbl (filename, image)
          VALUES ('image.gif', EMPTY_BLOB());
          UPDATE image_tbl
          SET image = v_blob
          WHERE filename LIKE 'image.gif';
          DBMS_LOB.FileClose(v_srcfile);
          COMMIT;
    END;I hope that one will help you.
    yours sincerely
    Florian W.

Maybe you are looking for

  • Setting the file type in a file field

    Hi, I wonder if any body can help i am new to web application development, I am developing an asp application in dreamweaver 8, A few of my pages contain a file field which has a file browse button at the end of the field which works fine, now i want

  • Conversion of UOM TO KG'S Urgent!!!!!!!!!!!!!!!!!

    can any one tell me how to convert UOM TO KG'S. Is there any FM to do it.

  • Primary key foreign key remove problem

    hi expretrs, I create 5 tables in ddic. 1. zpr_cmp Company Master 2. zpr_dpt Department Master 3. zpr_dsg Designation Master 4. zpr_emp Employee master. 5. zpr_slm Salary Master. Foreign key reference in zpr_emp from table 1,2 and 3 created and table

  • How to run client from other machine in ejb

    Please help me this problem . When i run on local . Every thing is ok . But when i run from different machine , it not work . Although , i hava changed jnp://localhost:1099 to jnp:/xxx.xxx.xxx:1099 , xxx... this is my ipaddress . I am using : net bea

  • Why is XML content disappearing when converting to button?

    I've never had this issue before but when I try to convert a group of objects containing XML or just the text box containing XML content into a button the XML content vanishes from the Structure panel. Usually when clicking "convert to button" everyt