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.

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 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 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();
    }

  • 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.

  • Clob data type oracle to oracle issue

    Hi Guys
    i am unable to load clob data type and am getting the following error
    " java.lang.NumberFormatException: For input "string: "4294967295"
    i also have checked for clob data type in topology manager -- technology -- oracle -- data type
    and it is available.
    i have added the following statement in my parameter file
    set ODI_ADDITIONAL_JAVA_OPTIONS=%ODI_ADDITIONAL_JAVA_OPTIONS% " -Doracledatabasemetadata.get_lob_precision=false";
    but i don't see any statement like the one below after which i have to add the above statement.
    set ODI_ADDITIONAL_JAVA_OPTIONS="-Djava.security.policy=server.policy";
    please let me know how to make the clob data type work
    Regards
    janakiram

    Hi Sutirtha
    Yes i am able to view source data with clob data type by Right click onto your source datastore ---> View data
    I have checked metalink
    it says
    1. Oracle recommends the setting of the "get_lob_precision" flag to FALSE to avoid this message when dealing with LOB family datatypes (CLOB, BLOB, NCLOB, BFILE...).
    i have used the follwoing setting
    set ODI_JAVA_OPTIONS="-Djava.security.policy=server.policy"
    set ODI_ADDITIONAL_JAVA_OPTIONS=%ODI_ADDITIONAL_JAVA_OPTIONS% "-Doracledatabasemetadata.get_lob_precision=false"
    2. checked the internal id of CLOB data type and it ends with 999
    but still i have the same problem
    Regards
    janakiram

  • 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

  • How to create a domain index on NCLOB Column

    hi all,
    My database version is 10.2.0.1.
    Any body know how to create a domain index on nclob column.
    SQL> alter table test add (nclob1   nclob);
    Table altered.
    SQL> CREATE INDEX test_nclob ON test (nclob1) indextype is ctxsys.context
      2  /
    CREATE INDEX test_nclob ON test (nclob1) indextype is ctxsys.context
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-20000: Oracle Text error:
    DRG-10509: invalid text column: NCLOB1
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 364Regards
    Singh

    Any body know how to create a domain index on nclob columnNot possible per design/documentation:
    The column that you specify must be one of the following types: CHAR, VARCHAR, VARCHAR2, BLOB, CLOB, BFILE, XMLType, or URIType.
    «

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • ORDSYS.ORDIMAGE vs BLOB

    Dear all,
    I've designed a table with an ordsys.ordimage field for images. BIG MISTAKE, because there is no possibility to upload images from a form. I'd like to change it into a BLOB field but an error arises:
    "You cannot modify the column definition for types CLOB, NCLOB, BFILE, BLOBand Intermedia Object types(ORDSYS.ORDIMAGE, ORDSYS.ORDAUDIO, ORDSYS.ORDVIDEO). (WWV-17079)"
    Could I change it anyhow in order not to build a new table? I have a lot of forms referring to that table and I should change these forms too....(and we know it is pretty difficult)...
    I would appreciate any help.
    Tomas

    And you are possible to display blob from table in form s image item?
    I tried this, but it didn't go, can you tell me, how did you do?

  • 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.

Maybe you are looking for