Copying Long Raw Column Data to another table

hi everyone,
i am trying to Copy Long Raw Column Data to another table in the same schema. this is the situation
Table A (col1 number,col2 long raw) with 100 records
Table B (col1 number,col2 long raw) with 0 records
now i want to copy col2 of the table A into the column 2 of the table B. but long raw data cant be retrieved in a select statement so is there any specific procedure that will copy long raw data or there is any simple way.
i will be really grateful for anybody's help.
thanx
shakeel

Dust off that old SQL*PLUS command "COPY" ...
create table tablea (col1 number,col2 long raw)
insert into tablea values (1, testrawio.chartoraw('this is line one'));
insert into tablea values (2, testrawio.chartoraw('this is line two'));
insert into tablea values (3, testrawio.chartoraw('this is line three'));
create table tableb (col1 number,col2 long raw)
copy from scott/tiger@larry insert tableb (col1, col2) using select col1, col2 from tablea
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
   3 rows selected from scott@tiger.
   3 rows inserted into TABLEB.
   3 rows committed into TABLEB at DEFAULT HOST connection.
SQL>Now to prove it has worked :
begin
   for lr in (select col1, col2 from tableb)
   loop
      dbms_output.put_line('col1 = '||lr.col1||
                           ' and col2 contains long raw equivalent of '||testrawio.rawtochar(lr.col2));
   end loop;
end;
col1 = 1 and col2 contains long raw equivalent of this is line one
col1 = 2 and col2 contains long raw equivalent of this is line two
col1 = 3 and col2 contains long raw equivalent of this is line three
PL/SQL procedure successfully completed.
SQL> Note : In order to load some test data and prove the method works I made use of a package called "testrawio" located at http://www.classicity.com/oracle/htdocs/forums/ClsyForumID125/7.html
AMM

Similar Messages

  • Copy Long raw from one table to another.

    Hi
    I am trying to copy data from one table to another. Source has one Long Raw column. There are about million rows in source table. And I am using Oracle 8.1.5. Whenever I execute the copy command, I get the following error message: Can someone help me?
    SQL> set long 64000000
    SQL> set copycommit 1
    SQL> set arraysize 100
    SQL> COPY to test/test@testfix CREATE resume_bkup1 using select * from resume;
    Array fetch/bind size is 100. (arraysize is 100)
    Will commit after every array bind. (copycommit is 1)
    Maximum long size is 64000000. (long is 64000000)
    ERROR:
    ORA-01084: invalid argument in OCI call
    SQL>
    Thanks
    V Prakash

    insert into emp_personal(emp_no, emp_pic) select emp_no, emp_pic from emp_personal_old where empno = '10059'
    Read the documentation as suggested by sol.beach.
    And fix your front-end to use supported datatypes.

  • Copying long raw to other table??

    Hi everyone....
    I'm using oracle 10g.
    In my table i have a LONG RAW column to store images.
    Now i need to copy the data in LONG RAW to another table...
    Is this possible.. if yes then whats the procedure to copy the data from LONG RAW ??
    please help me in this query.....
    its very urgent.......
    is it possible using oracle 8i ??
    Thanks in advance....
    Regards,
    Santosh.Minupurey
    Edited by: Santosh.minupurey on Feb 16, 2009 11:23 PM

    No one could answer my query ?
    very strange......

  • Copy Long raw from oracle table to table

    Hi
    I am wondering if someone help me to move (copy) long raw data from one table to another. I want to do:
    select long_raw_data from table1;
    insert into table2 values (previously selected long raw value).
    I wrote the following small java code, but it doesn't work. I get the following exception:
    java.sql.SQLException: ORA-00936: missing expression.
    ---------- Code: ---------
    import java.net.URL;
    import java.sql.*;
    class myJDBC
    public static void main (String args[])
    try {
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    String url = "jdbc:oracle:thin:@test:1521:devtest";
    Connection con = DriverManager.getConnection (url, "test", "test");
         Statement stmt = con.createStatement ();
         Statement insStmt = con.createStatement ();
    ResultSet res = stmt.executeQuery (
    "SELECT resume_data FROM resume where rownum < 26 ");
    while (res.next ()) {
         byte[] bytes = res.getBytes(1);
         insStmt.executeUpdate("INSERT INTO TMP_RESUME VALUES (" + bytes + ")");
    // clean-up
    stmt.close ();
    con.close ();
    catch (Exception e) {
    System.out.println (e.getMessage ());
    e.printStackTrace ();
    ------------ Code ends ---------------
    Thanks for your help
    V Prakash

    use PreparedStatement :
    PreparedStatement insStmt = connect.prepareStatement("INSERT INTO TMP_RESUME VALUES (?)");
    while (res.next ())
    byte[] bytes = res.getBytes(1);
    insStmt.setBytes(1,bytes);
    insStmt.executeUpdate();
    I don't remember very querys with ORACLE,
    but you may be do this in one time with
    SELECT ...... INTO ....
    or
    INSERT ..... INTO ..... SELECT
    One of this is valid for ORACLE and the other for SYBASE ...

  • How to copy complete column data of a table control similar to ALV

    Hi All,
    I have a senario where i need to select one column of a Table control and press Ctrlc then the complete column details should be copied and be able to paste it in another colum using ctrlv.
    please suggest me how can i copy the complete column data similar to ALV .
    Thanks in advance .
    Edited by: ravi kumar on Sep 13, 2011 2:53 PM

    Dear Ravi
    I'm afraid there is no standard functionality for copy paste in ALV.
    You would need to develop something to achieve that - a button for example.
    Kind Regards
    /Ricardo Quintas

  • 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

  • Getting the contents of a LONG RAW column

    Hi, I'm using Oracle 8.1.7 with JDK 1.4.0, and I've got a dilemma. I have a table that has several columns, one column is a LONG RAW, the rest are just NUMBER or VARCHAR2. I need to transer the contents of particular rows to another table with the same structure. I've got a query the gets the correct rows, and I create and use a ResultSet to getInt(), getString(), and set the parameters of a PreparedStatement. Here's my problem, when I try to do a getBytes() on the LONG RAW column, it says "Stream already closed."
    I was able to get around this in the past by just doing another query where the only column I selected was the LONG RAW column. Then it would let me do the getBytes(). Unfortunately, besides being inefficient, it is not possible to have 2 queries any longer. I was reading a little about this in the documentation, but I couldn't get a very good feel for it. Is there a way I can do one query and select all the rows, and still be able to pull out that data? Is there anything I'm missing? It seems like it's harder than it should be. Any advice? Thanks!
    Tobin Juday

    OK, I may have spoken too soon. I still seem to have the problem. Here's a chunk of my code, am I missing something dumb? Thank you...
    resultSet1 = query1.getResultSet();
    insert = conn.prepareStatement("INSERT....?,?,?)");
    while (resultSet1.next())
    insert.setBytes(23,resultSet1.getBytes("progtxt"));
    insert.setInt(1, version);
    insert.executeUpdate();
    }

  • 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

  • ORA-22835: buffer too small when trying to save pdf file in LONG RAW column

    Hi,
    I get "ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (real : 125695, maximum : 2000)" when i trying to save a 120k pdf file in an Oracle Long Raw column using dotnet 4.0 and Entity FrameWork.
    Dim db As New OracleEntities
    Try
    Dim myEntity = (From e In db.TEXTE _
    Where e.TEXT_ID = txtTextId.Text _
    Select e).Single
    With myEntity
    If txtTextypeId.Text <> "" Then
    .TEXTYPE_ID = txtTextypeId.Text
    Else
    .TEXTYPE_ID = Nothing
    End If
    .TEXT_NUM = txtTextNum.Text
    .TEXT_NAME = txtTextName.Text
    .TEXT_DATE = dtTextDate.SelectedDate
    If DocAdded Then
    .TEXT_DOC = Document
    ElseIf DocDeleted Then
    .TEXT_DOC = Nothing
    End If
    End With
    db.SaveChanges()
    Document is an array of Byte and TEXT_DOC also (mapped to a long row column).
    is it possible to increase the size of the buffer ? how may i do it ?
    Thx in advance.
    Regards.

    Using a custom UPDATE or INSERT stored procedure for LONG RAW column with
    exceed-limit data may still get the following error.
    "ORA-01460: unimplemented or unreasonable conversion requested".
    One option is to use BLOB instead of LONG RAW in your table and regenerate your
    data model from the table. Then using the default UPDATE or INSERT statement
    (created by EF) should work.
    The following will modify your LONG RAW column to BLOB column.
    Disclaimers:
    1. It's irreversible--you cannot modify BLOB back to LONG RAW.
    2. I have not tried that when there are huge data in LONG RAW column.
    So be careful.
    alter table <your_table_name> modify <your_long_raw_type_column> blob;

  • Long Raw Column

    Hi Everybody,
    I am using Oracle 9i ver 9.1 & Developer 6. My requirement is to store documents in the database. For that I have created a Long RAW column in the table where I have to store that. On forms I have made an OLE Container whose OLE Class property is set to "Word.Document.8". When I run the form, everyting goes fine. I insert the record, with word documents, it saves. I cleared the form & when I query it gets back the document, ie I can open it by double clicking it. But, once I exit the screen, run it again & try to query, it fetches all other columns except the OLE container value. I mean when I query it after exiting once & running the screen again, it does not fetch that OLE container base table items value, which it displays if I query it, without exiting, ie, the time when I inserted the document in OLE container, saved it & cleared the screen.
    Anyone having a work around pls, reply.
    Thanks in Advance.
    [email protected]

    Hi,
    Yes the data is getting saved. As, when i clear the screen & then query again it displays the data. At SQL promp, when i qureied the table, it displays on a single "D" as the column values for all the rows, whether I had inserted any value for that row or not. I mean it was displaying "D" in all the rows, though, I have not inserted value in all rows in the Long Raw Column.
    Rgds,
    [email protected]

  • Restrict the LONG RAW Column with less than 32760 bytes in the SELECT

    When i am trying to access a LONG RAW Dataype wchich has characters greter than 32760 bytes i am getting this error.
    Error -6502: ORA-06502: PL/SQL: numeric or value error
    I came to know that PL/SQL will only be able to access the first 32760 bytes of a LONG RAW. If we try to fetch a LONG RAW from the database into PL/SQL variable which exceeds the 32760 byte limit then we encountered the above error.
    Can anyone tell to avoid this error can we write a query to restrict the output to get only those records which has LONG RAW length less than 32760 bytes.
    Since we canot use utl_raw.length() in the Select Statement, is there any function to restrict the the records for less than 32760 Bytes only for LONG RAW datatype, so that i will not get any records for more than 32760 bytes and we will not get this error.
    REquest you to please help.

    Hi
    we do not have an option of migrating the LONG RAW to BLOB or any kind of ALTER to the table.
    We want to restrict the use of Records from the Table which has data for LONG RAW column less than 32760 bytes, so that we will not get the PL/SQL numberic Error
    any function for LONG RAW that can be used in SQL like for varchar2 we can use
    select length(NAME) < 100 from tb_emp+
    i.e it will get records only which has NAME less than 100 characters.

  • 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

  • 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

  • Updating and inserting on Long Raw column

    Hi All,
    My source table contains LONG RAW column in XX databse. I have to fetch the data from this table in YY Databse using DB link and insert into same structured table. The problem is, i can not access the LONG RAW data for some rows which the size exceeding above 32k.
    My requirement is, i have to fetch and insert or update the record(Source and target table structure is same and dtabase is different).
    Please suggest the best way of handle this problem.
    Please let me know if you need more information.
    Thanks
    Ram
    Edited by: ram on Oct 19, 2008 2:11 PM
    Edited by: ram on Oct 19, 2008 2:12 PM

    We using the procedure to insert and update. Procedure will called to update or insert only one record at a time from XX databse to YY database.
    We are not using SQL * PLUS for this operation.
    Thanks
    Ram

  • 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

Maybe you are looking for