BLOB - help

Hi,
I am trying to flush & close the output stream after writing the object to BLOB. But both of these functions throws a IOException. This is what I do ..
BLOB blob = t_resultSet.getBLOB(1);
OutputStream blobOutput = blob.getBinaryOutputStream();
ObjectOutputStream oos = new ObjectOutputStream ( blobOutput );
blobOutput.flush();
blobOutput.close();
oos.flush();
oos.close();
On flush it says ..
java.io.IOException: ORA-00600: internal error code, arguments:
[ktsircinfo_num1
], [4290672316], [1022], [4093612], [], [], [], []
ORA-06512: at "SYS.DBMS_LOB", line 700
ORA-06512: at line 1
Moreover this problem is with read as wel ... meaning after you read and
then try a 'close' ..
Any thoughts ..?
Thx,
-Praveen Jani
null

I am trying to load a file to an oracle blob using Java JDBC
I keep getting oracle error ORA-01002 fetch out of range
then i tried to lock the table with an exclusive lock
i get error
ORA-22920: row containing the LOB value is not locked
Please help
Statement stmt = con.createStatement();
stmt.execute("lock table lobtable in row exclusive mode");
File myfile = new File("trace.txt");
iStream = new FileInputStream(myfile);
rset = stmt.executeQuery("select testlob from lobtable where id = 1111"$
if(rset.next())
BLOB newBlob = (BLOB) ((OracleResultSet) rset).getBlob(1);
oStream = newBlob.getBinaryOutputStream();
int length = 0;
int pos = 0;
byte buf[] = new byte[1000];
while ((iStream != null) && (oStream != null) && ((length = iStream.read(buf$
System.out.println(
"Pos = " + Integer.toString(pos) + ". Length = " +
Integer.toString(length));
pos += length;
oStream.write(buf, pos, length);
iStream.close();
oStream.flush();
stmt.close();
oStream.close();
con.close();

Similar Messages

  • Oracle text search for BLOB help

    Hi folks,
    I am trying to build app for searching BLOB content(mainly ppts and pdfs)
    I am able to upload and download files as well but the below search code give me error.
    Can you please review and advise what I am doing wrong or what needs to  be fixed in the code.(ideally the code should give me the list of docs that have the search string I enter)
    Code :
    declare
    v_name  varchar2(100);
    v_doc blob ;
    begin
    select name, doc into v_name,v_doc
    from BLOB_TABLE
    where CONTAINS(doc,:P2_GO)>0;
    end;
    Error I get when I run the code is :
    ORA-01422: exact fetch returns more than requested number of rows

    LKSwetha wrote:
    Hi folks,
    I am trying to build app for searching BLOB content(mainly ppts and pdfs)
    I am able to upload and download files as well but the below search code give me error.
    Can you please review and advise what I am doing wrong or what needs to  be fixed in the code.(ideally the code should give me the list of docs that have the search string I enter)
    should give list of docs??? Read this http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/selectinto_statement.htm
    SELECT...INTO can only return one single row, thats why you will get an ORA-01422
    declare
    v_name  varchar2(100);
    v_doc blob ;
    begin
    select name, doc into v_name,v_doc
    from BLOB_TABLE
    where CONTAINS(doc,:P2_GO)>0;
    end;
    Error I get when I run the code is :
    ORA-01422: exact fetch returns more than requested number of rows
    What are you trying to do with above code as I don't see any logic that uses those variables? and is this code inside an apex component?

  • How to store the pdf file

    hi all,
    i need a pl/sql code to store the pdf file into the oracle database using blob.
    help me.
    Thanks in advance

    rabbott wrote:
    My first question is "where is the PDF file located"? If the answer is "on a file system accessible to the Oracle database" Then you can use directory objects and the DBMS_LOB package. It would look something like this:
    as SYS user do:
    -- assume the PDF files are in /data/documents <font face="tahoma,verdana,sans-serif" size="1" color="#000">files</font>ystem directory
    create or replace directory pdfdir as '/data/documents';
    grant read on directory pdfdir to <USER>;
    as USER do:
    create table mydocs (id integer primary key, doc blob);
    declare
    bf bfile;
    b blob;
    src_offset integer := 1;
    dest_offset integer := 1;
    begin
    -- insert a new blob and return it to local variable
    insert into mydocs values(1, empty_blob()) returning doc into b;
    -- open the bfile for file "summary.pdf"
    bf := bfilename('PDFDIR', 'summary.pdf');
    dbms_lob.loadBlobFromFile(b, bf, dbms_lob.lobmaxsize, dest_offset, src_offset);
    -- done
    commit;
    end;
    /I have the issue which is similar to what you have faced, I'll follow what you said to take a try, Thanks a lot!

  • Need help to open a blob from a report into another tab or browser window.

    Hello everyone.
    I'm looking for a bit of guidance on something I'm trying to do in Apex.
    I have a report that contains a blob. Users can click on the link to open it in same browser. I also know how to make it download if they click the link. But what I really want to do is to click the link and open the blob in another tab or browser window.
    Thank you in advance for your help.
    Dw
    I should have noted I'm using version 3.2
    Edited by: DW Brown on Feb 22, 2012 3:13 PM

    DW Brown wrote:
    It becomes a link from the column format section..
    DOWNLOAD:<tablename>:<column>:ID::MIMETYPE:FILENAME:LAST_UPDATE_DATE::inline:Click Here
    So far I haven't found a way to use something link "target=_blank"One way would be to use a Dynamic Action to apply the <tt>target="_blank"</tt> attribute to each link, or convert them to use APEX pop-ups or a jQuery lightbox like fancyBox.
    Create an example on apex.oracle.com if you need more assistance.

  • Need help to parse a blob

    I'm trying to write an app to parse unified patch files. I've got a table to hold a set of patches from a single patch file and a table to hold each individual patch within the patch file (a single patch file can patch multiple source files). I'm currently holding the file contents in a blob field. I know how I would do this in python or other scripting languages, but I'm a complete pl/sql n00b, so I'm a bit clueless. Basically, I have the appropriate algorithm for parsing the file, but just not how to do it.
    Does anyone know of a tutorial that explains how to do this? Or maybe post some tips as to what pl/sql modules to look into?

    Kindly go through the following links ->
    http://www.oracle.com/technology/sample_code/tech/windows/odpnet/howto/anonyblock/index.html
    http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/blob/blob.html
    http://www.psoug.org/reference/dbms_lob.html
    Might be helpful for you.
    Regards.
    Satyaki De.

  • Help with displaying BLOBs in OBIEE 11g

    I am trying to get OBIEE 11g to display photographs in an Analysis report. I know BLOB fields are not supported, and I have been reading posts on this board and following examples on internet sites that try to get round this problem. But, try as I might, I cannot get those pesky photos to display.
    Below are all the steps I have followed. Sorry that there is a lot to read, but I was hoping that somebody has been successful in doing this, and may spot something in one of my steps that I am doing wrong.
    ORACLE TRANSACTIONAL SOURCE_
    Table : EMPL_PHOTO
    Fields:
    USN VARCHAR2(11) ( Unique Key )
    EMPLOYEE_PHOTO BLOB ( I think the photos are stored as 'png' )
    ORACLE WAREHOUSE SOURCE_
    Table : D_PERSON_PHOTO_LKUP
    Fields :
    PERSON_KEY     NUMBER(38,0) ( Primary Key - Surrogate )
    USN     VARCHAR2(11)
    PHOTO     CLOB
    BLOB to CLOB conversion.
    I used this function :
         create or replace function blob_to_clob_base64(p_data in blob)
         return clob
         is
         l_bufsize integer := 16386;
         l_buffer raw(16386);
         l_offset integer default 1;
         l_result clob;
         begin
         dbms_lob.createtemporary(l_result, false, dbms_lob.call);
         loop
         begin
         dbms_lob.read(p_data, l_bufsize, l_offset, l_buffer);
         exception
         when no_data_found then
         exit;
         end;
         l_offset := l_offset + l_bufsize;
         dbms_lob.append(l_result, to_clob(utl_raw.cast_to_varchar2(utl_encode.base64_encode(l_buffer))));
         end loop;
         return l_result;
         end;
         select usn, employee_photo ,
         BLOB_TO_CLOB_BASE64(employee_photo)
         from empl_photo
    IN OBIEE ADMINISTRATION TOOL_
    *1) Physical Layer*
    Added D_PERSON_PHOTO_LKUP from Connection Pool
    Left it as 'Cachable'
    Didn't join it to any tables
    Changed field PHOTO to a 'LONGVARCHAR' length 100000
    Set USN as the Key ( not the surrogate key )
    *2) BMM Layer*
    Dragged D_PERSON_PHOTO_LKUP across.
    Renamed it to 'LkUp - Photo'
    Ticked the 'lookup table' box
    Removed the surrogate key
    Kept USN as the Primary key
    The icon shows it similar to a Fact table, with a yellow key and green arrow.
    On Dimension table D_PERSON_DETAILS (Dim - P01 - Person Details) added a new logical column
    Called it 'Photo'
    Changed the column source to be derived from an expression.
    Set the expression to be :
    Lookup(DENSE
    "People"."LkUp - Photo"."PHOTO",
    "People"."Dim - P01 - Person Details"."USN" )
    Icon now shows an 'fx' against it.
    Note: This table also had it Surrogate key removed, and USN setting as primary key.
    *3) Presentation Layer*
    Dragged the new Photo field across.
    Saved Repository file, uploaded, and restarted server.
    ONLINE OBIEE_
    Created a new Analysis.
    Selected USN from 'Person Details'
    Selected Photo from 'Person Details'
    Selected a measure from the Fact table
    Under column properties of Photo ( data format ) :
    - Ticked 'Override Default Data Format' box
    - Set to Image URL
    - Custom text format changed to : @[html]"<img alt="" src=""@H"">"
    Under column properties of Photo ( edit formula ) :
    - Changed to : 'data:image/png;base64,'||"Person Details"."Photo"
    The Advanced tab shows the sql as :
         SELECT
         0 s_0,
         "People"."Person Details"."USN" s_1,
         'data:image/png;base64,'||"People"."Person Details"."Photo" s_2,
         "People"."MEASURE"."Count" s_3
         FROM "People"
         ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST
         FETCH FIRST 65001 ROWS ONLY
    Going into the 'results' tab, get error message:
    +State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 17001] Oracle Error code: 932, message: ORA-00932: inconsistent datatypes: expected - got CLOB at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)+
    It doesn't seem to be using the Lookup table, but can't work out at which step I have gone wrong.
    Any help would be appreciated.
    Thanks

    Thanks, yes I followed http://docs.oracle.com/cd/E28280_01/bi.1111/e10540/busmodlayer.htm#BGBDBDHI, but when I get to the part of setting the LOOKUP function on th Physical source, only ONE physical source is displayed. I need TWO sources ( The Employee Table, and the Photo LookUp.
    I have raised this as an error with Oracle. We are now on OBIEE 11.1.1.7, but Oracle say BLOBS are still not supported in that release. It will be fixed in 11.1.1.8 and it will be backported into 11.1.1.6.11
    In the meantime we have abandoned showing Photo's in any of our reports.

  • How to load externl files (PDF) into BLOB column.  Please help.

    Hi All,
    I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
    Regards,
    Trang

    Hi,
    If the following link helps to you then great.
    http://www.exefind.com/oralobeditor-P25468.html
    Regards,
    Sailaja

  • Help:- Store Word file in database using blob

    Hai all,
    i want to store word document in database and reterieve from database but i don't have any idea i heared about blob but i don't know how to make it any one have source code or example form pls send me
    email: [email protected]

    Hello,
    First of all, you have got to be granted the privilege to read and write to the file system, this is a must to use BFile read access.
    A global function bfilename returns a bfile taking the file path as an argument is needed to construct a blob object through dbms_lob.loadfromfile.
    A very helpful example I found on orafaq follows:Create a link to the directory where the file to load in the blob is
    (connect as system then grant read privilege to your user):
    create or replace directory blob_dir as 'C:\Documents';
    Custom the following procedure that I copied from a Thread
    create or replace procedure blob_ins(p_id in number, p_filename in
    varchar2) as
    l_bfile bfile;
    l_blob blob;
    begin
    insert into blob_test(p_id, empty_blob())
    returning blob_file into l_blob;
    l_bfile := bfilename('BLOB_DIR', p_filename);
    dbms_lob.fileopen(l_bfile);
    dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
    dbms_lob.fileclose(l_bfile);
    commit;
    return;
    end blob_ins;
    You can use UTL_FILE package in another way, but this is much more safe;
    Have Fun
    Hossam Al Din

  • Trigger to blob column in Oracle - Need Help

    Hi,
    I need any help on Oracle Trigger
    I have two table
    - BIODATA_TABLE
    - ADM_GALERY_PICTURE
    All two table contain column SPIC_PICTURE2 that is blob column.
    If the picture column update in table BIODATA_TABLE, i want it to update also in ADM_GALERY_PICTURE,
    I have created the trigger to BIODATA_TABLE.
    When i try to update the picture, the picture on the ADM_GALERY_PICTURE does not updated.
    Below is my trigger, Please help me to correct it
    CREATE OR REPLACE TRIGGER TRANSFER_PICTURE_TRIGGER
    AFTER INSERT OR UPDATE
    ON BIODATA_TABLE
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    tmpVar NUMBER;
    BEGIN
    tmpVar := 0;
    IF UPDATING
    THEN
    UPDATE ADM_GALERY_PICTURE
    SET SPIC_PICTURE2 = :NEW.SPIC_PICTURE2
    WHERE ADM_GALERY_PICTURE.SPIC_BIODATA_ID = :NEW.SPIC_BIODATA_ID;
    END IF;
    EXCEPTION
    WHEN OTHERS
    THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END TRANSFER_PICTURE_TRIGGER;
    thanks

    user450549 wrote:
    Hi,
    I need any help on Oracle Trigger
    I have two table
    - BIODATA_TABLE
    - ADM_GALERY_PICTURE
    All two table contain column SPIC_PICTURE2 that is blob column.
    If the picture column update in table BIODATA_TABLE, i want it to update also in ADM_GALERY_PICTURE,
    I have created the trigger to BIODATA_TABLE.
    When i try to update the picture, the picture on the ADM_GALERY_PICTURE does not updated.
    Below is my trigger, Please help me to correct it
    CREATE OR REPLACE TRIGGER TRANSFER_PICTURE_TRIGGER
    AFTER INSERT OR UPDATE
    ON BIODATA_TABLE
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    tmpVar NUMBER;
    BEGIN
    tmpVar := 0;
    IF UPDATING
    THEN
    UPDATE ADM_GALERY_PICTURE
    SET SPIC_PICTURE2 = :NEW.SPIC_PICTURE2
    WHERE ADM_GALERY_PICTURE.SPIC_BIODATA_ID = :NEW.SPIC_BIODATA_ID;
    END IF;
    EXCEPTION
    WHEN OTHERS
    THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END TRANSFER_PICTURE_TRIGGER;
    thankswithout your tables & without your data we can't run or test your code.
    the picture on the ADM_GALERY_PICTURE does not updated.OK, I believe you, but what EXACTLY does occur?

  • Need  URGENT help with BLOB!!!!

    Hi,
    I am using a certain java server that has the capability of persisting objects to permanent storage (Oracle 8.1.5.0 in my case).
    The server automatically creates all necessary tables, and some of them have columns of BLOB datatypes in them.
    Then server retrieves a row of data and attempts to figure out how big is the size of the single BLOB record.
    All these queries are in xml configuration files and the server's java code uses them to access the database. I can not modify the datatypes during table creation without modifying actual server code, which I don't want to do for obvious reasons. I can't use stored procedures to figure out the size of the BLOB either for the same reason.
    Now here is the problem:
    Some of the logic of the code depends on queries that are supposed to return the size of BLOB data. Queries look like this:
    SELECT DATALENGTH(col_a)
    FROM table_A
    WHERE col_b = 'something'
    and of course col_a is in table_A and its datatype is BLOB (The sql above works on MS SQL).
    IS THERE AN EQUIVALENT OF datalength() IN ORACLE?
    I have unsuccessfully tried LENGTH(blob), which throws ORA-00932 inconsistent datatypes error. Also tried octet-length(), BLOB SIZE() with same results (different error: ORA-00923 FROM keyword not found where expected).
    Any ideas?
    Your help is greatly appreciated,
    Gugo M

    Thank you so much!
    Looks very simple (probably is for a dba).
    Thanks again.
    Gugo

  • Sql.Blob:   java.sql.SQLException: Funzione non supportata   .....help me

    Hello,
    I hope you can help me :-) !!!!!!
    I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
    resultSet rs = ****query****
    ((oracle.jdbc.oracleSet) rs ).getBLOB(1);
    but throws ClassCastException on the cast oracleSet......
    i try withthis code:
    ResultSet rs = ****query****
    Blob b = rs.getBlob(1);
    OutputStream out = b.setBinaryStream(1);
    but throws java.sql.SQLException: Funzione non supportata
    Why?????
    what's can i do?
    help me!!!!!!!
    thanks

    Hello,
    I hope you can help me :-) !!!!!!
    I have a EJB, in a metod of EJB i would update a object blob in a database. So i get a old blob from database by
    resultSet rs = ****query****
    ((oracle.jdbc.oracleSet) rs ).getBLOB(1);
    but throws ClassCastException on the cast oracleSet......
    i try withthis code:
    ResultSet rs = ****query****
    Blob b = rs.getBlob(1);
    OutputStream out = b.setBinaryStream(1);
    but throws java.sql.SQLException: Funzione non supportata
    Why?????
    what's can i do?
    help me!!!!!!!
    thanks

  • Oracle Blob using Java help (Error: JVM_recv in socket input stream read )

    I am trying to insert a record with Blob column (size of image 'mg.jpg' about 15KB) and I get the runtime error:
    [java] java.sql.SQLException: Io exception: Connection reset by peer: JVM_recv in socket input stream read
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
    [java]      at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061)
    [java]      at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    [java]      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
    [java]      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    [java]      at test.ProvisioningParser.TestBlob.main(Unknown Source)
    This is what code looks like: I am not sure what's wrong, any help appreciated. Thanks!
         try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("jdbc:oracle:thin:@VALUED-20606295:1521:dbbook","jvending","jvending");
                   java.util.zip.ZipInputStream zip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(new java.io.File("D:\\work\\mywork\\source\\test\\ProvisioningParser\\test.par"))) ;
                   int len = 0 ;
                   java.util.zip.ZipEntry entry = null;
                   do{
                        entry = zip.getNextEntry();
                        if (entry != null){
                             if (entry.getName().equalsIgnoreCase("mg.jpg")){
                                  len = (int)entry.getSize();
                                  break;
                   }while(entry!=null) ;
                   stmt = con.prepareStatement( "Insert into icon (parid, clientbundleid, id, iconfile ) values ( ?,?,?,?)"
                         stmt.setString(1,"101");
                         stmt.setString(2,"101");
                         stmt.setInt(3,1);                    
                         stmt.setBinaryStream( 4, zip, len);
                   stmt.setQueryTimeout(0);
                   stmt.executeUpdate();
                   con.close();               
              catch(Exception e){
                   e.printStackTrace();
              }Thanks,
    Rashmi

    As a guess what you are doing with that zip stuff is very odd.
    You do realize that it is just going to put some binary data into the blob right? And the methods that is going to use will not necessarily create a 'complete' zip file?
    If you want a zip file then just load the file, dont use the zip classes.
    And if you want part of a zip file, (and want to store the parts as a zip) then extract it from the file and create another zip entity using a byte stream rather than a file.
    Finally I suspect your error with the blob occurs because you do not close the statement. But at any rate you should figure out how to do the blob code independent of the zip stuff.
    And what oracle driver version are you using? Some of the older ones need oracle specific handling for blobs.

  • Please help, I need to read blob and output in bytes from wwv_flow_files.

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
    if (blob==null) return null;
    try {
    InputStream in = blob.getBinaryStream();
    int len = (int) blob.length(); //read as long
    long pos = 1; //indexing starts from 1
    byte[] bytes = blob.getBytes(pos, len);
    in.close();
    return bytes;
    catch (Exception e) {
    System.out.println(e.getMessage());
    return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    The example on this page is showing how to read a blob in portions you determine yourself:
    http://apex.oracle.com/pls/otn/f?p=31517:91
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Need some help extracting images from blobs...

    hi,
    I want to upload a image to a oracle blob and then download it and display it into a browser using jsp. I am new to java as will as oracle and doing a project for the first time. I have searched the internet and found out some links:
    http://fdegrelle.over-blog.com/article-992927-6.html
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006
    http://forums.devx.com/archive/index.php/t-142347.html
    I feel the solutions given are very vogue and also tried the solutions posted in java forums itself. I would like to have simple example, step by step explanation for uploading an image into a oracle blob,download the image and display it in a browser using a jsp so that i can understand the concepts.
    Thank you SUN and JAVA PROGRAMMERS.

    thanks yogee,
    The creators of these examples have assumed that the developers are advanced users. I am not an advanced user. I am not even a intermediate user.
    1.....................................I understood this(Create Table)
    create table demo
    ( id        int primary key,
      theBlob    blob
    )/2...................................I understood this too(I suppose we are mapping the folder path)
    create or replace directory my_files as '/export/home/tkyte/public_html';3..................................I understood this too(upload the file into the blob)
    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;
    /4..................................we are creating a package here. I got it.
    create or replace package image_get
    as
        procedure gif( p_id in demo.id%type );
    end;
    /5...................................we are suppose to use this to extract the file from the blob. But where does this get stored?
    create or replace package body image_get
    as
    procedure gif( p_id in demo.id%type )
    is
        l_lob    blob;
        l_amt    number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
    begin
        select theBlob into l_lob
            from demo
             where id = p_id;
            -- make sure to change this for your type!
        owa_util.mime_header( 'image/gif' );
            begin
               loop
                  dbms_lob.read( l_lob, l_amt, l_off, l_raw );
                  -- it is vital to use htp.PRN to avoid
                  -- spurious line feeds getting added to your
                  -- document
                  htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
                  l_off := l_off+l_amt;
                  l_amt := 4096;
               end loop;
            exception
               when no_data_found then
                  NULL;
            end;
    end;
    end;
    /6...............................Execute the procedure!
    exec image_get
    7..................................What after this step?
    I do not know servlets. I only know JSP? If you can please write a simple servlet to access the data and display it on the browser
    Sample servlet code is in the link as a last user comment. I couldn't understand head or tail.
    http://forums.devx.com/archive/index.php/t-142347.html
    I appreciate your help.
    Message was edited by:
    ted_anderson

  • 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

  • Concurrent mailbox moves from Exchange 2007 to 2013

    We are in the process of migrating from Exchange 2007 to Exchange 2013. We have about 200 mailboxes and we want to move them in groups of 40-50 at a time. I am trying to get more then 1 mailbox to actually sync to the new database at once. I start th

  • Vendor bank to company code

    Dear Forum, I check LFA1, LFBK, LFB1 to get the link of vendor bank to company code but could not get. LFA1 no bank information whereas LFBK no company code. Why there is no link? I need vendor bank which link to company code. I have same vendor in t

  • How To Back Up And Restore E-Mail?

    My Yahoo-based e-mail stopped working for some reason (won't accept password), but only in my iPad. Nothing has changed on the Mac or iPhone. So I'm going to delete the account and set it up again. However, I don't want to lose any e-mails I have sen

  • Personnel areas

    hi all, can i use same personnel area in two different company codes? if can't, plz explain the implication? ex: company code - 1100 and 1200 personnel area : bbbb regards

  • Doubts about my ABAP proxy scenario

    Hi everyone. I have this scenario. I think is simple but don't know how to do that. I have many questions for the forum. An abap proxy has to start a process in the XI Server. Data is stored in a R3 Backend and must be sent to XI Backend via ABAP pro