LONG RAW to CLOB Conversion

I wish to migrate records of a col. FILETYPE (LONG RAW) of existing table to col. DOCTYPE (CLOB) of a new table.
But the function to_lob() is unable to carry out the required migration. The Error message is : " Inconsistent Data Types expected - binary .... ".
Moreover LONG RAW to BLOB conversion works fine from a simple INSERT statement but the same fails when insertion is done using a CURSOR.
Can u guyz help me in doing the same !
Oracle Version used - 9i
Regards,
Chinmay <Infocker>

You can transfer data from
LONG to CLOB
LONG RAW to BLOB only..
In Oracle9i -- there is a very cool "alter table t modify long_col CLOB" to do
this as well....
you could convert a clob to a blob, or a blob to a clob using utl_raw.cast_to_varchar2/raw and doing it 32k at a time.

Similar Messages

  • How can I converting long raw in clob on Apex when I'm creating a view?

    I need some help. I'm creating a view and I need converting long raw fields in clob, varchar2, or char when I create a view.
    Thanks for your help.

    What error did you get when using the functions in a SELECT on a view? If that did not work, identify the table the view is based on and write the SELECT statement directly against that table and not the view.
    I do not understand, "I try and they are rights".
    Mike

  • Long Raw to CLOB

    Hi,
    I am in a situation to change one application which uses forms 5. and one table column uses LONG RAW. whose data type is as OLE CONTAINER in the form. which is populated by
    INITIALIZE_CONTAINER(item_id,file_path). here files path is MS word document.
    Now I want to shift the datatype from lang raw to CLOB, change in the table is OK but what changes required in the form? it is initializing the container but not saving in the table.
    Any help ?
    Regards

    You can transfer data from
    LONG to CLOB
    LONG RAW to BLOB only..
    In Oracle9i -- there is a very cool "alter table t modify long_col CLOB" to do
    this as well....
    you could convert a clob to a blob, or a blob to a clob using utl_raw.cast_to_varchar2/raw and doing it 32k at a time.

  • ORACLE8I - LONG TYPE을 LOB TYPE으로 CONVERSION하는 방법(TO_LOB)

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-12
    ORACLE8I - LONG TYPE을 LOB TYPE으로 CONVERSION하는 방법(TO_LOB)
    ===============================================================
    Purpose
    Long type의 data를 lob type으로 conversion하는 to_lob function에 대해
    알아보자.
    Explanation
    Oracle8 부터 long 이나 long raw type과는 별도로 lob type이 추가되었다.
    long 이나 long raw type을 clob 또는 blob type으로 변경하기 위해서는
    Oracle8 에서는 데이타를 다시 입력해야 했지만, Oracle8i 에서는 추가된
    TO_LOB function을 이용하여 간단히 data migration을 할 수 있다.
    TO_LOB function은 보통 create table .. as select .. 문장이나
    insert into .. select .. 문장에서 쉽게 사용할 수 있다.
    Example
    [예제1] long type의 데이타를 clob type으로 옮기는 방법
    아래의 예제에서 type만 long raw와 blob 로 바꾸어도 가능하다.
    SQL> create table long_data (c1 number, c2 long);
    Table created.
    SQL> desc long_data
    Name Null? Type
    C1 NUMBER
    C2 LONG
    SQL> insert into long_data values
    2 (1, 'This is some long data to be migrated to a CLOB');
    1 row created.
    SQL> create table test_lobs
    2 (c1 number, c2 clob);
    Table created.
    SQL> desc test_lobs
    Name Null? Type
    C1 NUMBER
    C2 CLOB
    SQL> insert into test_lobs
    2 select c1, to_lob(c2) from long_data;
    1 row created.
    SQL> select c2 from test_lobs;
    C2
    This is some long data to be migrated to a CLOB
    [예제2] long type을 clob type으로 바꾸어 table 생성하는 방법
    SQL> create table clob_data
    2 as select c1, to_lob(c2) c2 from long_data;
    Table created.
    SQL> desc clob_data
    Name Null? Type
    C1 NUMBER
    C2 CLOB
    [예제3] long raw type을 blob type으로 바꾸어 table 생성하는 방법
    SQL> desc image_data
    Name Null? Type
    C1 NUMBER
    C2 LONG RAW
    SQL> create table blob_data
    2 as select c1, to_lob(c2) c2 from image_data;
    Table created.
    SQL> desc blob_data
    Name Null? Type
    C1 NUMBER
    C2 BLOB

    You may not insert LONGs into a table that are selected from a remote database. You can simply SELECT LONGs across a DB link, but you just can't INSERT... SELECT them.
    Greg Pike
    http://www.singlequery.com

  • PLSQL 을 사용해서 LONG RAW 를 BLOB 으로 바꾸는 방법

    제품 : PL/SQL
    작성날짜 : 2002-10-16
    PLSQL 을 사용해서 LONG RAW 를 BLOB 으로 바꾸는 방법
    ======================================
    PURPOSE
    PLSQL 을 사용해서 LONG/LONG RAW 를 BLOB/CLOB 으로 바꾸는 방법을
    예제를 통해 알아봅니다.
    만일 Oracle 9i v9.x 를 이용하는 경우에는 다음 명령을 사용하실 수 있습니다.
    ALTER TABLE 'TABLE with LONG column' MODIFY ('LONG column' CLOB)
    또는
    ALTER TABLE 'TABLE with LONG RAW column' MODIFY ('LONG RAW column' BLOB)
    Example
    Example #1
    Example #1 은 LONG column 에 64k 이하의 data 가 있을 경우
    PL/SQL 을 이용해서 BLOB 으로 바꾸는 예제 입니다.
    -- table 을 drop 합니다.
    drop table traw;
    drop table tblob
    -- table 을 생성합니다.
    create table traw (n1 number , l1 long raw);
    create table tblob (n1 number , l1 blob);
    --- clob 도 사용 가능합니다.
    -- table 에 insert 합니다.
    begin
    for i in 1..10 loop
    insert into traw values (i,utl_raw.cast_to_raw(rpad(to_char(i),60,'&')));
    insert into tblob values (i,empty_blob());
    end loop;
    end;
    declare
    lobloc blob;
    buffer long raw(32000);
    amount number ;
    offset number := 1;
    begin
    for rec in (select * from traw) loop
    select l1 into lobloc from tblob where n1=rec.n1 for update;
    buffer := rec.l1;
    amount := utl_raw.length(rec.l1);
    dbms_lob.write(lobloc,utl_raw.length(rec.l1),1,buffer);
    end loop;
    end;
    Example #2
    다음은 PL/SQL 를 이용해서 LONG columns 을 BLOBs 로 변환하는
    또 다른 방법입니다.
    REM long2lob.sql
    REM Version 1.0, last updated 8/8/97
    REM This procedure copies LONG data into a CLOB, as described in
    REM Chapter 21 of Oracle8 PL/SQL Programming by Scott Urman.
    CREATE OR REPLACE PROCEDURE Long2Lob(
    -- Uses DBMS_SQL to select a LONG column identified by p_LongQuery, and
    -- returns it in p_CLob.
    p_LongQuery IN VARCHAR2,
    p_CLob IN OUT CLOB) AS
    c_ChunkSize CONSTANT INTEGER := 100;
    v_CursorID INTEGER;
    v_RC INTEGER;
    v_Chunk VARCHAR2(100);
    v_ChunkLength INTEGER;
    v_Offset INTEGER := 0;
    BEGIN
    -- Open the cursor, define, execute, and fetch.
    v_CursorID := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(v_CursorID, p_LongQuery, DBMS_SQL.V7);
    DBMS_SQL.DEFINE_COLUMN_LONG(v_CursorID, 1);
    v_RC := DBMS_SQL.EXECUTE_AND_FETCH(v_CursorID);
    -- Loop over the LONG, fetching c_ChunkSize characters at a time from
    -- the LONG and adding them to the LOB.
    LOOP
    DBMS_SQL.COLUMN_VALUE_LONG(v_CursorID, 1, c_ChunkSize, v_Offset,
    v_Chunk, v_ChunkLength);
    DBMS_LOB.WRITE(p_CLob, v_ChunkLength, v_Offset + 1, v_Chunk);
    IF v_ChunkLength < c_ChunkSize THEN
    EXIT;
    ELSE
    v_Offset := v_Offset + v_ChunkLength;
    END IF;
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR(v_CursorID);
    EXCEPTION
    WHEN OTHERS THEN
    -- Clean up, and reraise the error.
    DBMS_SQL.CLOSE_CURSOR(v_CursorID);
    RAISE;
    END Long2Lob;
    Reference Documents
    Note:1012454.7
    Note:168975.1

  • How can i read a stored picture in oracle Long Raw datatype? blob or clob?

    How can i read a stored picture in oracle Long Raw datatype? Like a blob or clob?....i am using jdk 1.3
    This is because...i tried to read it like a blob but i obtain a exception...about Type of column no valid......but the column exist....and it contains the long raw datatype of the pictures.....this is my code:
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.InputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.DriverManager;
    import oracle.sql.BLOB;
    import oracle.sql.BLOB.*;
    import oracle.jdbc.driver.*;
    import java.sql.*;
    class rec_ima1
    public static void main(String h[])
    Connection con = null;
    Blob bl;
    final ImageIcon image1;
    JPanel photo;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
    String query = "Select * from pictures where ID = '18840'";
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery( query );
    if (!rs.next())
    System.out.println("Empty Result Set");
    bl = rs.getBlob(5);
    if (bl == null) {
    System.out.println("Null Blob");
    return;
    InputStream is = bl.getBinaryStream();
    int imageLength = (int) bl.length();
    System.out.println(imageLength);
    System.out.println(bl.length());
    byte[] imageData = new byte [imageLength];
    is.read(imageData, 0, imageLength);
    image1 = new ImageIcon(imageData);
    photo = new JPanel() {
    public void paint(Graphics g){
    g.setColor(Color.lightGray);
    g.drawImage(image1.getImage(), 0, 0, this);
    } catch (Exception e) {
    e.printStackTrace();
    Now i tried using clob:
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.InputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.DriverManager;
    import oracle.sql.CLOB;
    import oracle.sql.CLOB.*;
    import oracle.jdbc.driver.*;
    import java.sql.CallableStatement;
    class rec_ima4
    public static void main(String h[])
    Connection con = null;
    Clob cl;
    JPanel photo;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    con= DriverManager.getConnection("jdbc:oracle:thin:@123.3.12.213:1521:db_name","user","password");
    con.setAutoCommit (false);
    String query = "Select * from pictures where ID = '18840'";
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery( query );
    while (rs.next()) {
    oracle.sql.CLOB clob = (CLOB) rs.getObject(5); //line 47
    } catch (Exception e) {
    e.printStackTrace();
    This is the runtime exception:
    java.lang.ClassCastException: [B
    at rec_ima4.main(rec_ima4.java:47)

    Thanks by answering to me......
    Well....i did that....but what is ImageIO?....
    I declared a ImageIcon imageIO, but this give me the following:
    rec_ima3.java:49: cannot resolve symbol
    symbol : class BufferedImage
    location: class rec_ima3
    BufferedImage bi = ImageIO.read(bInput);
    ^
    rec_ima3.java:49: cannot resolve symbol
    symbol : variable ImageIO
    location: class rec_ima3
    BufferedImage bi = ImageIO.read(bInput);
    ^
    What classes i have to import?.....what is ImageIO?
    Thanks

  • LONG RAW - Conversion Error

    Hi,
    We are having a d/b with oracle 7.0 having a column LONG RAW. Client Signatures are stored in the form of Tiff in this column. We are now trying to extract the same and write it in the file system of a different server.
    We are encountering a peculiar problem. For certain cases the conversion and writing part goes of smoothly, but for some cases we are getting an ORACLE error ORA-1460 conversion error while using UTL_RAW.CAST_TO_VARCHAR2 .
    This does not happen for all cases, please help us solve the same

    Hi,
    We are having a d/b with oracle 7.0 having a column LONG RAW. Client Signatures are stored in the form of Tiff in this column. We are now trying to extract the same and write it in the file system of a different server.
    We are encountering a peculiar problem. For certain cases the conversion and writing part goes of smoothly, but for some cases we are getting an ORACLE error ORA-1460 conversion error while using UTL_RAW.CAST_TO_VARCHAR2 .
    This does not happen for all cases, please help us solve the same

  • 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

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

  • How to insert data from file into long raw field using utl_file?

    I try to insert binary data from a file (under AIX 4.3.3) into a LONG
    RAW field (Oracle 8.1.6).
    First, I retrieve the data from the file like this:
    DECLARE
    FileHandle = UTL_FILE.FILE_TYPE;
    myVariable LONG RAW;
    FileHandle := UTL_FILE.FOPEN ;('prj/oracle/admin/MARTIJN/udump',
    'MyFile.ATT', 'R');
    UTL_FILE.GET_LINE (FileHandle, myVariable);
    UTL_FILE.FCLOSE(FileHandle);
    INSERT INTO myTable(DUMMYFIELD) VALUES(myVariable);
    Where DUMMYFIELD of table myTable is of type LONG RAW.
    The GET_LINE statement crashes on Oracle Error ORA-6502: Numeric of
    Value error: hex to raw conversion error.
    What do I do wrong?
    Do I use the right method to retrieve information from a file and put
    it into a long raw field, should I try it another way?
    Any help greatly appreciated,
    Martijn Rutte

    Zarina,
    To clarify your problem, you have a script node contaning your Matlab code. Are you then using the standard LV functions to load in your data from a file and pass it into the script node?
    Regards
    Tristan

  • Importing a file containing long raw data

    I have got a .dmp file which was exported from an oracle 8i database & contains a long raw column.Now, when i try to import this file in to oracle 9i database, the import says,
    C:\>imp
    Import: Release 9.2.0.1.0 - Production on Sat Aug 20 14:51:03 2005
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: sys@mydb2 as sysdba
    Password:
    Connected to: Personal Oracle9i Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Import file: EXPDAT.DMP > invoice_content.dmp
    Enter insert buffer size (minimum is 8192) 30720>
    Export file created by EXPORT:V08.01.07 via conventional path
    Warning: the objects were exported by TPSYSADM, not by you
    import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    export client uses US7ASCII character set (possible charset conversion)
    export server uses US7ASCII NCHAR character set (possible ncharset conversion)
    List contents of import file only (yes/no): no >
    Ignore create error due to object existence (yes/no): no >
    Import grants (yes/no): yes >
    Import table data (yes/no): yes >
    Import entire export file (yes/no): no >
    Username: tpsysadm
    Enter table(T) or partition(T:P) names. Null list means all tables for user
    Enter table(T) or partition(T:P) name or . if done:
    . importing TPSYSADM's objects into SYS
    Import terminated successfully without warnings.
    Now, when i query from the sys user, i dont find any object with the name invoice_contents.
    Can any 1 help me out of the above problem.
    Thanks in advance.

    The import seems OK, but it also seems that no rows have been imported, maybe no tables. What is the result of :
    SQL> select owner, table_name from dba_tables where table_name like '%INVOICE%';
    BTW, is the name invoice_content or invoice_contents ?
    If the query does not give result, then try to check the content of your dmp file
    C:\> imp user/password@db file=invoice_content.dmp full=y show=y
    Paul

  • Copy Long Raw from table 1 to another table in Oracle 8i

    I have 2 similar tables in Oracle 8i.
    Table 1:
    Id number;
    blob_obj long raw;
    Table 2:
    Table 1:
    Id number;
    blob_obj long raw;
    Is there any way to copy the data from table to table 2 ?
    Is it possible to do some conversions are load it ?
    Kindly provide pointers for this issue.

    See this thread Re: Getting LONG RAW from remote database for some useful ideas.
    Regards Nigel

  • Migration of LONG and LONG RAW datatype

    Just upgraded a DB from 8.1.7.4 to 10.2.0.1.0. In the post-upgrade tasks, it speaks of migrating tables with LONG and LONG RAW datatypes to CLOB's or BLOB's. All of my tables in the DB with LONG or LONG RAW datatypes are in the sys, sysman, mdsys or system schemas (as per query of dba_tab_columns). Are these to be converted? Or, does Oracle want us to convert user data only (user_tab_columns)?

    USER_TAB_COLUMNS tells you the columns in the tables owned by the current user. There may well be many users on your system that you created that contain objects. I suppose you could log in to each of those schemas and query their USER_TAB_COLUMNS table, but it's probably easier to query DBA_TAB_COLUMNS with an appropriate WHERE clause on the owner of the objects.
    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

  • PL/SQL Help...Long Raw to BLOB

    Hello All,
    I have a PL/SQL Package and Function that does a search for text in a blob field. Below is the Package and the Function.
    Here the statement that executes the function
    Select *
               FROM PROGTXT
              WHERE pcode.str_loc_in_blob
                                        (pcode.blob_to_new_blob (progtxt),
                                         '<search string>'
                                        ) <> 0
           ORDER BY objectvalue1, objectvaluesCurrently the above mentioned sql works where the progtxt is a blob datatype.
    We have a database where the progtxt is of Long Raw datatype. I want to utilize the same sql exactly but change the function where i can copy the table structure to a global temporary table each time the function is executed using the dbms_lob funtion and delete the temp table once the function is executed after the results are posted/retrieved. The reason why i want to use the same application is because it is part of a .net program and the only thing i change is the function. I am not great with PL/SQL. If anyone can help that will be a great help!!!!!
    Below is the code for the package and the function
    CREATE OR REPLACE PACKAGE PCODE AS
    FUNCTION to_base (p_dec IN NUMBER, p_base IN NUMBER)
       RETURN VARCHAR2
    FUNCTION to_dec (
       p_str         IN   VARCHAR2,
       p_from_base   IN   NUMBER DEFAULT 16
       RETURN NUMBER
    FUNCTION to_hex (p_dec IN NUMBER)
       RETURN VARCHAR2
    FUNCTION to_bin (p_dec IN NUMBER)
       RETURN VARCHAR2
    FUNCTION to_oct (p_dec IN NUMBER)
       RETURN VARCHAR2
    FUNCTION str_to_hex(p_str IN VARCHAR2)
    RETURN VARCHAR2
    FUNCTION str_loc_in_blob(
      l_blob IN BLOB
    , l_str  IN VARCHAR2)
    RETURN NUMBER
    FUNCTION blob_to_new_blob(
      p_blob IN BLOB)
    RETURN BLOB
    END PCODE;
    CREATE OR REPLACE PACKAGE BODY PCODE AS
    FUNCTION to_base (p_dec IN NUMBER, p_base IN NUMBER)
       RETURN VARCHAR2
    IS
       l_str   VARCHAR2 (255) DEFAULT NULL;
       l_num   NUMBER         DEFAULT p_dec;
       l_hex   VARCHAR2 (16)  DEFAULT '0123456789abcdef';
    BEGIN
       IF (p_dec IS NULL OR p_base IS NULL)
       THEN
          RETURN NULL;
       END IF;
       IF (TRUNC (p_dec) <> p_dec OR p_dec < 0)
       THEN
          RAISE PROGRAM_ERROR;
       END IF;
       LOOP
          l_str := SUBSTR (l_hex, MOD (l_num, p_base) + 1, 1) || l_str;
          l_num := TRUNC (l_num / p_base);
          EXIT WHEN (l_num = 0);
       END LOOP;
       RETURN l_str;
    END to_base;
    FUNCTION to_dec (
       p_str         IN   VARCHAR2,
       p_from_base   IN   NUMBER DEFAULT 16
       RETURN NUMBER
    IS
       l_num   NUMBER        DEFAULT 0;
       l_hex   VARCHAR2 (16) DEFAULT '0123456789abcdef';
    BEGIN
       IF (p_str IS NULL OR p_from_base IS NULL)
       THEN
          RETURN NULL;
       END IF;
       FOR i IN 1 .. LENGTH (p_str)
       LOOP
          l_num :=
             l_num * p_from_base + INSTR (l_hex, UPPER (SUBSTR (p_str, i, 1)))
             - 1;
       END LOOP;
       RETURN l_num;
    END to_dec;
    FUNCTION to_hex (p_dec IN NUMBER)
       RETURN VARCHAR2
    IS
    BEGIN
       RETURN to_base (p_dec, 16);
    END to_hex;
    FUNCTION to_bin (p_dec IN NUMBER)
       RETURN VARCHAR2
    IS
    BEGIN
       RETURN to_base (p_dec, 2);
    END to_bin;
    FUNCTION to_oct (p_dec IN NUMBER)
       RETURN VARCHAR2
    IS
    BEGIN
       RETURN to_base (p_dec, 8);
    END to_oct;
    FUNCTION str_to_hex(p_str IN VARCHAR2)
    RETURN VARCHAR2 IS
    l_val VARCHAR2(2000) := NULL;
    BEGIN
       FOR i IN 1 .. LENGTH (p_str)
       LOOP
          l_val := l_val || to_hex(ASCII(SUBSTR (p_str, i, 1))) || case when i = LENGTH (p_str) then null else '00' end;
       END LOOP;
       RETURN UPPER(l_val);
    END str_to_hex;
    FUNCTION str_loc_in_blob(
      l_blob IN BLOB
    , l_str  IN VARCHAR2)
    RETURN NUMBER IS
    blob_len NUMBER;
    l_pos number := 0;
    BEGIN
    blob_len := dbms_lob.getlength(l_blob);
    l_pos := 0;
    FOR i in 0..15 LOOP
        l_pos := dbms_lob.instr(DBMS_LOB.SUBSTR (l_blob, 2000, i*2000+1), IMPACTUS_PCODE.str_to_hex((l_str)));
        IF l_pos <> 0 THEN
           RETURN i*2000+1 + l_pos - 1;
        END IF;
    END LOOP;
    FOR i in 0..15 LOOP
        l_pos := dbms_lob.instr(DBMS_LOB.SUBSTR (l_blob, 2000, i*2000+1), IMPACTUS_PCODE.str_to_hex(upper(l_str)));
        IF l_pos <> 0 THEN
           RETURN i*2000+1 + l_pos - 1;
        END IF;
    END LOOP;
    l_pos := 0;
    FOR i in 0..15 LOOP
        l_pos := dbms_lob.instr(DBMS_LOB.SUBSTR (l_blob, 2000, i*2000+1), IMPACTUS_PCODE.str_to_hex(lower(l_str)));
        IF l_pos <> 0 THEN
           RETURN i*2000+1 + l_pos - 1;
        END IF;
    END LOOP;
    l_pos := 0;
    FOR i in 0..15 LOOP
        l_pos := dbms_lob.instr(DBMS_LOB.SUBSTR (l_blob, 2000, i*2000+1), IMPACTUS_PCODE.str_to_hex(initcap(l_str)));
        IF l_pos <> 0 THEN
           RETURN i*2000+1 + l_pos - 1;
        END IF;
    END LOOP;
    RETURN 0;
    END str_loc_in_blob;
    FUNCTION blob_to_new_blob(p_blob BLOB)
       RETURN BLOB IS
    v_file_blob     BLOB;  
    v_file_blob_new BLOB := NULL;
    v_file_clob     CLOB;  
    v_file_size     INTEGER := dbms_lob.lobmaxsize;
    v_dest_offset   INTEGER := 1;
    v_src_offset    INTEGER := 1;
    v_blob_csid     NUMBER := dbms_lob.default_csid;
    v_lang_context  NUMBER := dbms_lob.default_lang_ctx;
    v_warning       INTEGER;
    BEGIN
    DBMS_LOB.CREATETEMPORARY(v_file_clob, TRUE);
            dbms_lob.convertToClob(
                            v_file_clob,
                            p_blob,
                            v_file_size,
                            v_dest_offset,
                            v_src_offset,
                            v_blob_csid,
                            v_lang_context,
                            v_warning);
            v_file_clob:=upper(v_file_clob);
            IF v_warning = 0 THEN
                    v_file_size     := dbms_lob.lobmaxsize;
                    v_dest_offset   := 1;
                    v_src_offset    := 1;
                    v_blob_csid     := dbms_lob.default_csid;
                    v_lang_context  := dbms_lob.default_lang_ctx;
                    v_warning       := null;
                    DBMS_LOB.CREATETEMPORARY(v_file_blob_new,true);
                    dbms_lob.convertToBlob(
                            v_file_blob_new,
                            v_file_clob,
                            v_file_size,
                            v_dest_offset,
                            v_src_offset,
                            v_blob_csid,
                            v_lang_context,
                            v_warning);
                    IF v_warning = 0 THEN
                       RETURN v_file_blob_new;
                    END IF;  
            END IF;
    END;
    END PCODE;
    /Thanks
    Nitin
    Edited by: user13048604 on Jan 12, 2011 10:18 PM

    First you may need to convert 'BLOB' which is of 'RAW' type to 'VARCHAR2'
    using
    utl_raw.cast_to_varchar2(urblob)Then you can make use of dbms_lob.instr,dbms_lob.substr etc...

Maybe you are looking for

  • Report output is not diplaying

    Hi Experts, Good morning! When i try to execute the HR report  the out put of some of the employees CTC is not displaying and other employess dipalying , only this issue some of the employees only .Can any one suggested me how to solve this issue. i

  • Does iPhoto refresh a folder of images?

    First of all: what a stunning bit of kit! While I have had iPhoto in one form or another I have not really had time to give it a work through and it is certainly impressive. I suppose I need guidance on two matters: 1 - is it possible to have two lib

  • A new useful feature to PC Suite ...

    ... would be the ability to make a note of backups of phones made via PC Suite which are viewable outside of PC Suite. The reason for this is that I often back my phone up when I make a change to it. However it is impossible to tell what change I bac

  • Need docs. for IDoc & RFC

    Hi All, Please help me with documents of IDoc & RFC. Thanks in advance. Regards, Sree

  • Save XXL list object in SAPoffice issue

    Hello, One of my user recently got a new laptop and after that, whenever she used KSB1 to do the export to excel as pivot, she is getting the below option "Save XXL list object in SAPoffice". She is not getting the pivot table option. I tried to find