How to load image in Long Raw column?

Dear all,
I need to upload a jpg image to a Long Raw column in one of our tables. Is there a way or utility so that I can do this thru a PL/SQL code? Please help.
Regards,
Amit

You must not be using LONG data type. It has been deprecated. You must be using BLOB. Here is an extract from AskTom.com on how to load a file into BLOB field.
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;
/Below is the link for the same.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006

Similar Messages

  • Loading Images into LONG RAW column using SQL or PL/SQL

    Hi!
    I am trying to load images into a LONG RAW column. Can anybody tell me how to do this using SQL or PL/SQL. I do not want to use Forms to do this. And, I have a limitation using BLOBs.
    Thanks in Advance,
    Kotesh.

    You wrote that you cannot use a java class to insert a picture. We are working on a school project and HAVE to use java as a client and Oracle 7 as a server.
    Can you tell us how this is to be done?
    Thank you in advance,
    Bart van der Heijden

  • How to insert records with LONG RAW columns from one table to another

    Does anybody know how to use subquery to insert records with columns of LONG RAW datatype from one table to another? Can I add a WHERE clause in the subquery statement? Thanks.

    Insert into ... Select statements are not supported for long or long raw. You will have to either use PL/SQL or convert your long raw to blobs.

  • Insert image to long raw column Oracle 9i PL/SQL

    I am trying to insert a .jpg image into an Oracle 9i table datatype long raw. I am coding in PL/SQL. I have researched inserting images and all I get back is the cool dbms_lob utility info. I cant change the column type to a blob - the database is a people soft delivered table and I am not allowed to change it.
    Has anyone done this?
    Does anyone have sample code?
    Pretty Please (I need any help I can get)
    Kelli

    user10506010 wrote:
    Can u provide me a solution for this...Can you read the title of this forum?
    >
    Forum: Community Feedback and Suggestions (Do Not Post Product-Related Questions Here)
    Use this forum for feedback about OTN programs, Web site content, and systems - product-related questions will be deleted.

  • How to move data of LONG RAW column to another table?

    I want to transfer the Long Raw datatype from A ( a Long Raw) to B (b Long Raw) in PL/SQL. The data of a colum is bigger than 32KB
    Pls help me to advise how to do that?
    Thanks a lot for your reply.

    Example:
    begin
      insert into a values(utl_raw.cast_to_raw(12345654));
      commit;
      for c in (select a from a) loop
          insert into b values(c.a);
      end loop;
      commit;
    end;

  • Inserting into long raw column type

    Hello,
    We tried to insert into a bmp file into the a column of type long raw and got the following error: "invalid value stored in pcbValue". There was no ORA message code assign to this error.
    Willy

    Thanks !
    JDeveloper Team (guest) wrote:
    : Hi,
    : You need to use streams to do this. In the JDBC User's Guide
    and
    : Reference, there is a whole chapter on using streams. Here is
    : some example code from the 8.1.5 JDBC User's Guide:
    : The following Java code snippet writes the data from the
    LESLIE
    : LONG RAW column into a file called
    : leslie.gif:
    : ResultSet rset = stmt.executeQuery ("select GIFDATA from
    : streamexample where
    : NAME='LESLIE'");
    : // get first row
    : if (rset.next())
    : // Get the GIF data as a stream from Oracle to the client
    : InputStream gif_data = rset.getBinaryStream (1);
    : try
    : FileOutputStream file = null;
    : file = new FileOutputStream ("leslie.gif");
    : int chunk;
    : while ((chunk = gif_data.read()) != -1)
    : file.write(chunk);
    : } catch (Exception e) {
    : String err = e.toString();
    : System.out.println(err);
    : } finally {
    : if file != null()
    : file.close();
    : In this example the contents of the GIFDATA column are
    : transferred incrementally in chunk-sized pieces between
    : the database and the client. The InputStream object returned
    by
    : the call to getBinaryStream() reads the data
    : directly from the database connection.
    : Zvonimir Vukovi (guest) wrote:
    : : Zvonimir Vukovic (guest) wrote:
    : : : Hi !
    : : : I have a problem when inserting an image (eg. GIF file)
    : into
    : : : Long Raw column. I am using JDeveloper 1.1, and I need to
    : read
    : : : images from my local hard drive and insert them into
    Oracle
    : : : DBMS. I've done a reverse thing (copying image from Long
    Raw
    : : : column to my HDD). I would be very thankful for a piece of
    : : JDBC
    : : : code which would solve my problem.
    : : : Thanks,
    : : : Zvonimir Vukovi
    : : I've forgotten to say that I need to use na Applet to do
    the
    : : job. I can read the image into AWT Image control, but I
    don't
    : : know how to get it into the Long Raw column
    : : Thanks again.
    : : Z.V.
    null

  • Updating a LONG RAW column

    I have a table with a column of type LONG RAW that can take binary content of arbitrary length (up to 2 GB). I try to copy content from one row to another using the following SQL:
    UPDATE TEAM_ADM.Content SET (Content, ContentType) =
    (SELECT Content, ContentType FROM Content WHERE ContentId = in_SourceContentID)
    WHERE ContentID = in_TargetContentID;
    Content.Content is the column in question.
    Oracle returns with error ORA-00997:
    ORA-00997 illegal use of LONG datatype
    Cause: A value of datatype LONG was used in a function or in a DISTINCT, WHERE, CONNECT BY, GROUP BY, or ORDER BY clause. A LONG value can only be used in a SELECT clause.
    Action: Remove the LONG value from the function or clause.
    Question: How can I copy a LONG RAW column from one row to another?
    Regards,
    Kjell Tangen

    Hello,
    It seems that the Long datatypes in Oracle have a lot of restrictions. According to
    this blog:LONG and LONG RAW columns cannot be used in distributed SQL statements.
    In that case, you should update the long raw column on the Oracle side. You can try to use openquery as Rick post above to send the SQL statment to Oracle and execute.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Load image file into a LONG RAW column via SQL*Loader

    Does anyone know how to load a image file into a LONG RAW column via SQL*Loader?
    Thanks
    -Hsing-Hua-

    Are you trying to import the image on the client into Oracle lite, or from the server end into the main oracle database for download to the client?
    On our system images are loaded into the the oracle lite database (10g R1 at the moment) on the client (DELL X50 PDA's) into a BLOB (Not LONG RAW) column using Java (relatively standard functionality in Java) as this is what our application software is written in.
    From the server end, we do not at the moment load images as such, but we do load the application software into the database for deployment of new versions to the clients (the DMC/DMS updates we have found very unreliable), and the technique should be the same for images. Again the file is imported into a BLOB column.
    NOTE a column defined as BLOB on the main Oracle database appears as a LONG VARBINARY on the client Oracle lite database, but the synchronisation process handles the conversion with no problem.
    To import into a BLOB column on the server try the following
    1) you will need to create a DIRECTORY (CREATE DIRECTORY command) within the database, pointing at a directory on the database server (or accessible from it). This is needed for the file location.
    CREATE OR REPLACE DIRECTORY PDA_FILE_UPLOAD AS '/pdaapps/jar/'
    NOTE create directory needs to be run as SYSTEM
    2) define your table to hold the image and other data. Our tables is
    SQL> desc pda_applications
    Name Null? Type
    ID NOT NULL NUMBER(12)
    PDAAT_CODE NOT NULL VARCHAR2(10)
    VERSION NOT NULL NUMBER(5,2)
    PART_NO NOT NULL NUMBER(3)
    FILE_OBJECT BLOB
    DEPLOY_APPLICATION_YN NOT NULL VARCHAR2(1)
    3) copy the image (or in our case a .jar file) to the database server directory specified in step 1
    4) the actual import is done using a DBMB_LOB procedure
    PROCEDURE pr_load_file
    Module Name     :     pr_load_file
    Description     :     Main call. Create a new pda_applications record, and import the specified file into it
    Version History:
    Vers. Author Date Reason
    1.0 G Wilkinson 03/02/2006 Initial Version.
    (PA_VERSION IN NUMBER
    ,PA_FILENAME IN VARCHAR2
    ,PA_PDAAT_CODE IN VARCHAR2
    ,PA_PART_NO IN NUMBER DEFAULT 1
    ,PA_DEPLOY IN VARCHAR2 DEFAULT 'Y')
    IS
    l_FileLocator BFILE;
    l_blobLocator BLOB;
    l_seq NUMBER;
    l_location VARCHAR2(20);
    no_params EXCEPTION;
    call_fail EXCEPTION;
    BEGIN
    -- Throw error if required details not present
    IF pa_version IS NULL
    OR pa_filename IS NULL
    OR pa_pdaat_code IS NULL THEN
    RAISE no_params;
    END IF;
    -- Initialize the BLOB locator for writing. Note that we have
    -- to import a blob into a table as part of a SELECT FOR UPDATE. This locks the row,
    -- and is a requirement for LOADFROMFILE.
    SELECT pdaa_id_seq.nextval
    INTO l_seq
    FROM dual;
    -- First create the application record (file is imported by update, not insert
    INSERT INTO pda_applications
    (ID,PDAAT_CODE,VERSION,PART_NO,FILE_OBJECT,DEPLOY_APPLICATION_YN)
    VALUES (l_seq,pa_pdaat_code,pa_version,pa_part_no,EMPTY_BLOB(),pa_deploy);
    -- Lock record for update to import the file
    SELECT file_object INTO l_blobLocator
    FROM pda_applications
    WHERE id=l_seq
    FOR UPDATE;
    -- Initialize the BFILE locator for reading.
    l_FileLocator := BFILENAME('PDA_FILE_UPLOAD', pa_filename);
    DBMS_LOB.FILEOPEN(l_FileLocator, DBMS_LOB.FILE_READONLY);
    -- Load the entire file into the character LOB.
    -- This is necessary so that we have the data in
    -- character rather than RAW variables.
    DBMS_LOB.LOADFROMFILE(l_blobLocator, l_FileLocator
    ,DBMS_LOB.GETLENGTH(l_FileLocator)
    ,src_offset => 1);
    -- Clean up.
    DBMS_LOB.FILECLOSE(l_FileLocator);
    -- Create download records for each user associated with the application for sending to the PDA's
    -- to install the software
    IF pa_deploy = 'Y' then
    IF fn_deploy (pa_pdaa_id => l_seq
    ,pa_pdaat_code => pa_pdaat_code) != 'SUCCESS' THEN
    RAISE call_fail;
    END IF;
    END IF;
    EXCEPTION
    WHEN no_params THEN
    pkg_appm.pr_log_message( pa_mdl_name => g_module_name
    , pa_mdl_version => fn_get_body_version
    , pa_error_code => SQLCODE
    , pa_location => l_location
    , pa_text => 'Missing parameters'
    , pa_severity => 'E'
    WHEN OTHERS THEN
    DBMS_LOB.FILECLOSE(l_FileLocator);
    pkg_appm.pr_log_message( pa_mdl_name => g_module_name
    , pa_mdl_version => fn_get_body_version
    , pa_error_code => SQLCODE
    , pa_location => l_location
    , pa_text => SQLERRM
    , pa_severity => 'E'
    END pr_load_file;
    I hope this may be of some help

  • How to differentiate picture formats in LONG RAW column?

    Hi,
    I have a table with a long raw column that contains pictures. I would like to know for each row if the picture in the long raw column is in JPEG, TIFF, BMP, etc.
    Does somebody have an idea on how to do this?
    Thanks!
    Matt

    1) You really shouldn't be using LONG or LONG RAW data types any longer. You should at least be using BLOB data types here.
    2) When you designed the schema, there should have been columns (or other tables) to store metadata about the file, including the type of image a row stores.
    3) Lacking any of this, you could write a program that fetches the data and determines whether it is a valid JPEG, then checks to see if it is a valid TIFF, etc. until it happens upon a file format that appears to work. Obviously, though, that is a relatively costly exercise. If that's what you're forced to do, I'd strongly encourage you to store that information in a (potentially new) column in the database so you only have to do it once.
    Justin

  • URGENT - Extract Image Files From Long Raw Column

    Hi.
    I have to extract image files (tif and wmf format) from "long raw" column and put them in a directory, using a PL/SQL procedure.
    Can anyone help me.
    Thanks

    Well that is interesting, that ORA returns no records on Metalink. Anyway, that was for my own curiosity.
    As you are on 10g, this is how I would write a long raw to a file if I had no choice:
    1) create a gtt with a column of type blob
    2) insert into the gtt the long raw column using the to_lob conversion function
    3) you now have a lob!
    4) open a binary file for writing using utl_file (binary mode was introduced in 10g)
    4) use dbms_lob to read through the blob and write it in chunks to the file
    You will have to do this row by row. It will be painfully excrutiatingly slow.
    This is basically your only choice unless you have a OCI programmer to hand. In which case I would be getting them to write the C code to read the long raw column and write it to a file. This could then be compiled into a library and called as an external procedure from PL/SQL.
    HTH
    Chris

  • HOW TO RETRIEVE A LONG RAW COLUMN FROM A TABLE AND WRITE TO OS FILE

    Good evening.
    Please how can I read a long raw datatype from a table and insert into an operating system file using PL/SQL.
    Thank you.

    What does this have to do with LONG RAW? It is about UTL_FILE and not especially great code.
    The question is how to retrieve and write LONG RAW and that is quite a different matter.
    First you must convert it to BLOB.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:13213885403654
    Then you can write it out to the file system
    http://www.morganslibrary.org/reference/utl_file.html
    Look at the "Extract Blob" demo

  • 6i to 9i conversion OLE container stored in a LONG RAW column to BLOB

    I need to automate the migration of data stored in a long raw column to a blob column. The objects were stored in the long raw column using an Oracle Forms 6i OLE container. There is also multiple object types stored in the column, ie (word, excel, images, but mostly pdf's). I have looked at the webutil package but cannot figure out how to read the long raw column since ole containers are obsolete in 9i. I have a lot of records that need migrating and need help.
    Thanks,
    J. Broome
    [email protected]

    It doesn't appear that I am able to attach the PDF files.  Can you supply your email (or I can supply mine) so I can send you the three files:
    1.)  A good PDF (manually extracted from our old application)
    2.)  Dump of the same PDF file (includes header/footer info)
    3.)  A partially fixed PDF file (but some of the pictures / pages are cut off - specifically pages 3,5,9,10,12,14)
    The way that we have tried to fix the file (in example 3 above) is the following:
    a.)  Find the First Occurrence of "%PDF-"
    b.)  Find the Last Occurrence of "%%EOF"
    c.)  if the first "%PDF-" is found AND the last "%%EOF" is found, then
       i.)  Remove all data before the first %PDF-
       ii.)  Remove all data after the last %%EOF
    Let me know if you need any other information.
    Thanks,
    Mike

  • How can i get a LONG RAW size? Please help me.

    Hi,
    I have one table (record) that contain 2 fields,
    image as LONG RAW and staffid as string.
    How can i make the select statement to get the actual size for each image?
    I have try to do " Select dbms_lob.getLength(image) as actualsize,staffid from record " ,
    but it get error "ORA-00997:illegal use of LONG datatype"
    Can any body help me ?thanks
    Message was edited by:
    user450549

    LONG RAW and BLOB are very different data types. Oracle has been suggesting for quite a while that folks migrate from LONG RAW to BLOB-- it's much easier to work with BLOB data than LONG RAW data...
    How much data, roughly, do you have in these columns. If it's relatively small, you may be able to use UTL_RAW.LENGTH. If it's longer, though, I believe you have to write a program that reads all the data and calculates the length as you go, which is obviously not particularly efficient...
    Justin

  • Sql Developer MSSql Migration, Online data move, image to long raw mapping

    Hello,
    my task is to migrate a MSSql Server Database to Oracle 10.2.0.4 with SQL Developer Version 2.1.1.64
    and JTDS JDBC Driver oracle.sqldeveloper.thirdparty.drivers.sqlserver 11.1.1.58.17.
    Capture, convert and online data move works except data mapping from MSSql image to Oracle long raw dataype.
    I need to map MsSql image to oracle blob, to achieve online data move!
    is Sql Developer online migration MsSql image to oracle long raw possible?
    I know that long raw is outdated, but i'm dba and not responsible for the software part.
    What options should i try? offline data move? can MS Bulk Copy Program export image data and SQL*Loader import into long raw?
    Any experience or tipp?
    Thanks
    Michael

    Hi user12132314 ,
    I do not see any 'long raw' options on our current SQLServer 2005 data type mapping. (Raw is a separate 2000 byte data type).
    The usual route for SQLDeveloper is to go to Blob.
    Online - this is simple & automated.
    Offline - this actually goes via hex output in bcp to sqlldr, read in as CLOB which is then encoded to blob. (This is automated)
    (Online 'Copy to Oracle' option, right click on table, may be of use if advanced features not included in the select such as defaults are not required, it copies over a select * from table, including blobs)
    To move you from blob to long raw after migration can be done (easily enough if Oracle database >=10g so the stream does not have to be in smaller 'chunks')
    http://asktom.oracle.com/pls/asktom/f?p=100:11:3938270166267830::::P11_QUESTION_ID:702825000306
    I can look into this if you want to go down this route.
    Note however that long raw has drawbacks and blob is preferred, see
    Oracle® Database SQL Language Reference
    11g Release 2 (11.2)
    Part Number E17118-04
    Data Types
    LONG Data Type
    for example one restriction is:
    A table can contain only one LONG column.
    -Turloch
    SQLDeveloper Team

  • Problems with LONG RAW column

    We have a LONG RAW column.
    JDev mapped it to Raw and LONGVARBINARY as SQL type.
    Reading data (even huge amounts) works alright, but when we try to insert or update we get:
    Data size bigger than max size for this type
    I did some reading on the internet and found that I had to stream data into JDBC which Raw apparently cannot handle.
    So how can I solve this?
    And please, don't just write "Create a domain". I tried. It's not that easy for me. It should be a bit more specific.
    Thanks in advance!
    Sascha

    You not only have to create a Domain but also implement either BlobDomainInterface or one of it's subclassed interfaces.
    See oracle.jbo.domain.BlobDomainInterface (source in bc4jdomorcl-src.zip) for an example of how various interface methods are implemented.
    When a domain implements BlobDomainInterface, it's called during load/save Entity data to setup it's transaction context (if it needs to during load) and to save it's content into the db using the given transaction context.
    These interfaces are written with the assumption that there's an oracle.sql.* class that knows how to use transaction to fetch data using SQL-locator objects. In this case I believe you will need to extend the domain from oracle.sql.RAW class.

Maybe you are looking for

  • Clob Columns gettting swapped in a table in Oracle 10G

    Hi Experts, When we try to insert a data into a table having two clob columns, if the data size increases more than 1000 characters, the contents of these two clob columns getting swapped. If it is less than 1000 characters, it works fine. We are usi

  • Iscsiadm -m node -L all results in errors

    Hi, I am following your document under http://www.oracle.com/technology/pub/articles/wartak-rac-vm.html When I get to the stage : iscsiadm -m node -L all which should log me into the filers all I get are errors. Everything is fine up until that point

  • Ejb & as400 toolbox jdbc

    Anyone having experience with ejb's running in WL4.5.1 on NT using connection pooling to an AS400 using ibm's java toolbox driver (V4R3) ? Any special info on the transaction isolation levels ? I'm very interested on encountered pitfalls and issues i

  • Itunes 7.3 does not open and i can't reinstall older versions

    the software upgrade made me download the last itunes version but it does not open (apparently i have an old version of macosx) and since then i can not use itunes. the old versions do not install. how could i reinstall itunes on my computer

  • My application manager will not open

    I can log into my creative cloud account, but cannot download After effects. Also my application manager will not open on my desktop.