Serialization Object and storasge in blob field Oracle 8.1.6

Hi,
this is problem with serializing and deserializing when i am storing object serialized in a Blob field Oracle:
MyObject myObject = new MyObject();
ByteArrayOutputStream bayos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream (bayos);
oos.writeObject(myObject);
oos.flush();
byte[] buffer = bayos.toByteArray();
int size = buffer.length;
oos.close();
ByteArrayInputStream bayis = new ByteArrayInputStream(buffer,0,size);
// if the number bytes of serialized myObject > 4kbytes then the insert in Blob field fails down.
// if the number bytes of serialized myObject < 4kbytes then the insert in Blob field successes.
// So I only can put in Blob field serialized object with size minus 4k.
// The code for insert:
PreparedStatement pstmt = connection.prepareStatement(sqlInsert);
pstmt.setBinaryStream(1,bayis,size);
int retCode = pstmt.executeUpdate();
// The code for read from table Oracle
rset = stmt.rxecuteQuery(sqlSelect);
rset.next();
oracle.sql.BLOB fldBlob = (BLOB)rset.getObject(1);
InputStream ins = fldBlob.getBinaryStream();
byte[] buf = new byte[size]
ByteArrayInputStream bayis = new ByteArrayInputStream(buf,0,size);
ObjectInputStream ois = new ObjectInputStream(bayis);
MyObject myObject = (MyObject)ois.readObject();
Someone knows the reason of the limit of 4Kbyte ?
Thanks....

Insert LOBs into Oracle is a 3 step process. You must insert a place holder, and the do a select for update to put the contents into the row. Lets say you have a table called MY_LOB:
create table MY_LOB (
   MYID NUMERIC(10) NOT NULL,
   MYLOB BLOB DEFAULT EMPTY_BLOB()
);The 'empty_blob' keyword tells Oracle to put a dummy value in the blob column when a row is initially created. To insert (assuming you have a db connection already):
conn.setAutoCommit(false);
PreparedStatement pstmt = null;
ResultSet rs = null;
oracle.sql.BLOB myLob = null;
try
   //Insert the initial row.
   pstmt = conn.prepareStatement("INSERT INTO MY_LOB (MYID) VALUES (?)");
   //Set the PK value
   pstmt.setInt(1,100);
   pstmt.executeUpdate();
   pstmt.close();
   //Lock the row for insertion.  This is needed for large inserts.
   pstmt = conn.prepareStatement("SELECT MYLOB from MY_LOB where MYID = ? FOR UPDATE");
   pstmt.setInt(1,100);
   rs = pstmt.executeQuery();
   if (rs.next())
      myLob = (oracle.sql.BLOB)rs.getBlob(1);
   rs.close();
   pstmt.close();
   //Finally...update the row with the blob data....
   myLob.putBytes(1, buffer);
   pstmt = conn.prepareStatement("UPDATE MY_LOB SET MYLOB = ? WHERE MYID = ?");
   pstmt.setBlob(1, myLob);
   pstmt.setInt(2,100);
   pstmt.executeUpdate();
   pstmt.close();
   conn.commit();
catch(SQLException sqlE)
    conn.rollback();
finally
  //make sure and close all statements....
}Hope this helps, I didn't compile it so it may have some bugs. It should lead in the right direction at least.

Similar Messages

  • Inserting and updating a BLOB field

    Friends I want my application (Oracle is the backend) to look for a character in a BLOB field and then replace it with the desired character.
    Can some one give me some example of retrieving and updating a BLOB field

    Examples are in Oracle Technet: http://otn.oracle.com/
    In this forum I saw also some examples and in your local Oracle Client Installation you find under $ORACLE_HOME$/jdbc/demo/ examples.
    reagrds Dietmar

  • Export table rows to Excel and save to BLOB field

    Hi all,
    I try to find out how export data from table to Excel file format and save the result to BLOB field in some other table.
    I know how to download report from Page by submit, but I need to process data and instead of returning result to user as Excel file - save it in BLOB.
    Also I found implementation on JAVA for the issue but actually I wanna study out - Is it possible to resolve this issue by PL/SQL and APEX API methods?
    So, any ideas :) ??
    Thanks,

    It is not very difficult.
    Here is the function I use to get a CSV file from a query :
    PROCEDURE get_query_result_as_csv_file(
         in_query    IN VARCHAR2,
         in_filename IN VARCHAR2)
    IS
         l_blob BLOB;
         l_raw     RAW(32767);
         l_cursor INTEGER;
         l_cursor_status INTEGER;
         l_col_count      NUMBER;
         l_col_val VARCHAR2(32767);
         l_desc_tbl sys.dbms_sql.desc_tab2;
    BEGIN
         -- create temporary BLOB
         dbms_lob.createtemporary(l_blob, FALSE);
         -- open BLOB
         dbms_lob.open(l_blob, dbms_lob.lob_readwrite);
         -- open cursor (and get cursor id)
         l_cursor := dbms_sql.open_cursor;
         -- parse query
         dbms_sql.parse(l_cursor,  in_query, dbms_sql.native);
         -- get number of columns and description
         dbms_sql.describe_columns2(l_cursor, l_col_count, l_desc_tbl);
         -- define report columns
         FOR i IN 1 .. l_col_count LOOP
              dbms_sql.define_column(l_cursor, i, l_col_val, 32767);
         END LOOP;
         -- write column headings to CSV file
         FOR i IN 1 .. l_col_count LOOP
              l_col_val := l_desc_tbl(i).col_name;
              IF i = l_col_count THEN
                   l_col_val := '"' || l_col_val || '"' || chr(10);
              ELSE
                   l_col_val := '"' || l_col_val || '",';
              END IF;
              l_raw := utl_raw.cast_to_raw(l_col_val);
              dbms_lob.writeappend(l_blob, utl_raw.length(l_raw), l_raw);
         END LOOP;
         -- execute the query
         l_cursor_status := dbms_sql.execute(l_cursor);
         -- write result set to CSV file
         LOOP
              EXIT WHEN dbms_sql.fetch_rows(l_cursor) <= 0 OR dbms_sql.last_row_count > 1000;
              FOR i IN 1 .. l_col_count LOOP
                   dbms_sql.column_value(l_cursor, i, l_col_val);
                   IF i = l_col_count THEN
                        l_col_val := '"' || l_col_val || '"' || chr(10);
                   ELSE
                        l_col_val := '"' || l_col_val || '",';
                   END IF;
                   l_raw := utl_raw.cast_to_raw(l_col_val);
                   dbms_lob.writeappend(l_blob, utl_raw.length(l_raw), l_raw);
              END LOOP;
         END LOOP;
         -- close cursor and BLOB
         dbms_sql.close_cursor(l_cursor);
         dbms_lob.close(l_blob);
         -- set http headers
         owa_util.mime_header('application/octet', FALSE);
         htp.p('content-length: ' || dbms_lob.getlength(l_blob));
         htp.p('content-disposition: attachment;filename="' || in_filename || '.csv"');
         owa_util.http_header_close;
         -- download the file
         wpg_docload.download_file(l_blob);
    END;If you need to get the query dynamically from your report, you can try to get the source from the apex_application_page_regions table :
    SELECT region_source
    FROM apex_application_page_regions
    WHERE application_id = 111 -- replace with your application id
    AND static_id = 'static_id_of_your_report'Then instead of using wpg_docload.download_file, simply insert the BLOB into your table.
    Good luck.
    Yann.

  • Weblogic and cmp with blob fields

    I have an entity bean with cmp. This bean has a blob field. When ejbCreate and
    ejbPostCreate methods are executed in this bean, exception saying "row containing
    the LOB value is not locked" is thrown.
    The transaction attribute for the method is set to RequiresNew in the deployment
    descriptor.
    Can someone suggest what may be going wrong here.
    Thanks

    I have an entity bean with cmp. This bean has a blob field. When ejbCreate and
    ejbPostCreate methods are executed in this bean, exception saying "row containing
    the LOB value is not locked" is thrown.
    The transaction attribute for the method is set to RequiresNew in the deployment
    descriptor.
    Can someone suggest what may be going wrong here.
    Thanks

  • How to show a picture from my database (BLOB field) Oracle into my JSP

    Hi all, i got a problem trying to show a picture in my JSP.
    I have a servlet which loads my picture, the problem is that i dont know how to set into a session// session.setAttribute("xxx","aaa") // or if there is another way to set it up, in order to show it in my JSP, if someone could help me i really appreciate it... thanks

    The way you include it in your jsp is the standard way you download any image.
    With an image tag
    <img src="myImageServlet?imageId=42"/>
    and your imageServlet actually returns the picture via its output stream.
    ie it makes 2 requests. One for the jsp page, and then when it receives and parses the html, one to the servlet to get the image.

  • Question: releasing value of BLOB field

    Hello, I'm using EclipseLink 2.0.
    I have an entity with @BLOB field, which is lazy loaded. After I update or persist an instance of the entity, I don't need the BLOB field value, because I need the memory to be free.
    Can I make the BLOB field uninitialized without entity's refresh (as if the object is just queried)? Or the only way is to refresh the entity?

    Refresh is the only public way.
    There is an internal way, get the FetchGroup from the object and remove the blob attribute name from it (or set a new FetchGroup if null), then just null out the blob.
    The class will be weaved to implement FetchGroupTracker, which provides the API to get and set the FetchGroup (or you can use the descriptor's FetchGroupManager).
    James : http://www.eclipselink.org

  • Loading class file stored in BLOB field

    - I am able to store and retrieve Java files and XML files in and from a BLOB field, but when I store a class file and try and load it using Class Loader, it us unable to load the class. The size of the class file increases by 1 byte when I retrieve it from the database. Is this some security feature by the JVM? Is it not possible to store, retrieve and load a class file from a database table?
    Thanks
    Harini

    Hi,
    First, I would suggest you use fiddler (http://www.telerik.com/fiddler) to compare these two different client requests, second, please try to use Azure Storage Explorer (http://azurestorageexplorer.codeplex.com/) to do
    this instead of the Azure Web Storage Explorer. 
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to display image in blob field in ResultSet in SiteStudio?

    I am running Site Studio 10gR4. For a custom page, I created a component that basically runs a query. The structure of the underlying data is a combination of Varchar2, Date and a single BLOB field. The blob field either contains a simple jpeg image, or nothing.
    In my Page where I am looping through the data, how do I display the blob as an image?
    Currently the code looks like this:
         <!--$loop SQLRoutes-->
              <tr>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 0))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 1))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 2))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 3))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 4))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 5))--></td>
                   <td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))--></td>
              </tr>
         <!--$endloop-->Field 1 is a blob and fields 5 and 6 are dates.
    So really two questions:
    1. How do I display field1 as an image?
    Example:
    <!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 1))-->doesn't do it. Is there a different function then getValue() that I should be using to get the blob contents?
    2. I want to compare the date fields to todays date, and either change the color or conditionally display the fields. I could do this with basic taglibs from jsp. How do I do this with IDocScript?
    Example:
    <!--$if getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6)) > dateCurrent-->
      <span class="red"><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))--></span>
    <!--$endif-->Thanks, Ken

    I actually don't know the answer to #1. If I were to guess, there's nothing out-of-the-box to handle blobs, so your best option is to write your own idoc function. Take a look at the How To component if you don't know how.
    For #2, you almost have it right. Insert bold:
    &lt;!--$if <b>parseDate(formatDate(</b>getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))<b>)) gt</b> dateCurrent<b>()</b>--&gt;
    &lt;span class="red"&gt;<!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))-->&lt;/span&gt;
    <!--$endif-->

  • Streaming blob fields

    i have an object that contains a blob field that i need to be able to
    read/write using streams, rather than creating a byte[] to hold the entire
    thing in memory at once. are there any ways to do this without resorting to
    jdbc? for example, are there any kodo-specific implementation classes that
    i can cast a jdo object to to get extra functionality, or any way to get at
    the underlying input streams kodo using to read blobs?
    any pointers/advice in this area would be greatly appreciated.
    thanks.

    I started what I think is the right approach. What I'm missing is how to
    create
    an extension to OracleBlobMapping so I don't get the:
    java.lang.ClassCastException
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.update(OracleBlob
    Mapping.java:
    69)
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.LobMapping.insert(LobMapping.java:1
    20)
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.ja
    va:491)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManag
    er.java:413)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManager
    Impl.java:549
    There are no source for the BlobMapping classes I think.
    We are using 2.4.0, but can upgrade to any Kodo including betas...
    Thanks,
    Eivind Skildheim
    Motive Communications, Inc
    "Abe White" <[email protected]> wrote in message
    news:[email protected]...
    We cannot commit to a timeframe on this. I can say, though, that we'll
    be continuing to make it easier to create your own FieldMapping in the
    short term (next 1-3 months; 3.0 release timeframe), so you should be
    able to create your own mapping to handle streaming LOBs. As noted
    before, you have this option at the present time too.begin 666 OracleDictionaryWithBlobs.java
    M<&%C:V%G92!C;VTN;6]T:79E+FID;RYK;V1O.PT*#0HO*BH-"B J($-O<'ER
    M:6=H=" R,# R(&)Y($UO=&EV92!#;VUM=6YI8V%T:6]N<RP@26YC+@T*("H@
    M06QL(')I9VAT<R!R97-E<G9E9"X-"B J#0H@*B!4:&ES('-O9G1W87)E(&ES
    M('1H92!C;VYF:61E;G1I86P@86YD('!R;W!R:65T87)Y(&EN9F]R;6%T:6]N
    M(&]F#0H@*B!-;W1I=F4@0V]M;75N:6-A=&EO;G,L($EN8RX@*")#;VYF:61E
    M;G1I86P@26YF;W)M871I;VXB*2X@(%EO=0T*("H@<VAA;&P@;F]T(&1I<V-L
    M;W-E('-U8V@@0V]N9FED96YT:6%L($EN9F]R;6%T:6]N(&%N9"!S:&%L;"!U
    M<V4@:70-"B J(&]N;'D@:6X@86-C;W)D86YC92!W:71H('1H92!T97)M<R!O
    M9B!T:&4@;&EC96YS92!A9W)E96UE;G0@>6]U#0H@*B!E;G1E<F5D(&EN=&\@
    M=VET:"!-;W1I=F4N#0H@*B\-"@T*:6UP;W)T(&IA=F$N:6\N26YP=713=')E
    M86T[#0II;7!O<G0@:F%V82YS<6PN0FQO8CL-"FEM<&]R="!J879A+G-Q;"Y0
    M<F5P87)E9%-T871E;65N=#L-"FEM<&]R="!J879A+G-Q;"Y297-U;'13970[
    M#0II;7!O<G0@:F%V82YS<6PN4U%,17AC97!T:6]N.PT*#0II;7!O<G0@:F%V
    M87@N:F1O+DI$3T5X8V5P=&EO;CL-"@T*:6UP;W)T(&-O;2YS;VQA<FUE=')I
    M8RYK;V1O+FEM<&PN:F1B8RYO<FUA<'!I;F<N17AP;&EC:71";&]B36%P<&EN
    M9SL-"FEM<&]R="!C;VTN<V]L87)M971R:6,N:V]D;RYI;7!L+FID8F,N;W)M
    M87!P:6YG+D)L;V)-87!P:6YG.PT*:6UP;W)T(&-O;2YS;VQA<FUE=')I8RYK
    M;V1O+FEM<&PN:F1B8RYO<FUA<'!I;F<N17AP;&EC:71/<F%C;&5";&]B36%P
    M<&EN9SL-"FEM<&]R="!C;VTN<V]L87)M971R:6,N:V]D;RYI;7!L+FID8F,N
    M;W)M87!P:6YG+D]R86-L94)L;V)-87!P:6YG.PT*:6UP;W)T(&-O;2YS;VQA
    M<FUE=')I8RYK;V1O+FEM<&PN:F1B8RYS8VAE;6$N9&EC="Y/<F%C;&5$:6-T
    M:6]N87)Y.PT*#0II;7!O<G0@;W)G+F%P86-H92YL;V<T:BY,;V=G97([#0H-
    M"G!U8FQI8R!C;&%S<R!/<F%C;&5$:6-T:6]N87)Y5VET:$)L;V)S#0H@(" @
    M97AT96YD<R!/<F%C;&5$:6-T:6]N87)Y#0I[#0H@(" @<')I=F%T92!#;&%S
    M<UM=(%]F:65L9$-L87-S97,@/2!N=6QL.PT*#0H@(" @<'5B;&EC($]R86-L
    M941I8W1I;VYA<GE7:71H0FQO8G,H*0T*(" @('L-"B @(" @(" @<W5P97(H
    M*3L-"B @("!]#0H@(" @#0H@(" @+RHJ#0H@(" @("H@0V]N=F5R="!V86P@
    M=&\@<W%L('9A;'5E#0H@(" @("HO#0H@(" @<'5B;&EC($]B:F5C="!B;&]B
    M5&]344P@*$]B:F5C="!V86PI#0H@(" @>PT*(" @(" @("!O<F<N87!A8VAE
    M+FQO9S1J+DQO9V=E<BYG971,;V=G97(H=&AI<RYG971#;&%S<R@I*2YI;F9O
    M*"(J*BH@8FQO8E1O4U%,(#HB("L@=F%L*3L-"B @(" @(" @:68@*"AN=6QL
    M("$]('9A;"D-"B @(" @(" @(" @("8F("AV86P@(3T@3W)A8VQE0FQO8DUA
    M<'!I;F<N14U05%E?0DQ/0BDI#0H@(" @(" @('L-"B @(" @(" @(" @("\O
    M('-T<F5A;7,N#0H@(" @(" @(" @("!R971U<FX@=F%L.R -"B @(" @(" @
    M?0T*(" @(" @("!E;'-E#0H@(" @(" @('L-"B @(" @(" @(" @(')E='5R
    M;B!S=7!E<BYB;&]B5&]344PH=F%L*3L-"B @(" @(" @?0T*(" @('T-"@T*
    M(" @('!U8FQI8R!/8FIE8W0@8FQO8D9R;VU344P@*%)E<W5L=%-E="!R<RP@
    M:6YT(&-O;'5M;BD-"B @(" @(" @=&AR;W=S(%-13$5X8V5P=&EO;@T*(" @
    M('L-"B @(" @(" @3&]G9V5R+F=E=$QO9V=E<BAT:&ES+F=E=$-L87-S*"DI
    M+FEN9F\H(BHJ*B!B;&]B1G)O;5-13" Z(B K(&-O;'5M;BD[#0H@(" @(" @
    M($)L;V(@8FQO8B ]("A";&]B*2!R<RYG971";&]B("AC;VQU;6XI.PT*(" @
    M(" @("!I9B H8FQO8B ]/2!N=6QL*0T*(" @(" @(" @(" @<F5T=7)N(&YU
    M;&P[#0H-"B @(" @(" @=')Y#0H@(" @(" @('L-"B @(" @(" @(" @("\O
    M(')E='5R;B!A<R!S=')E86T-"B @(" @(" @(" @(')E='5R;B!B;&]B+F=E
    M=$)I;F%R>5-T<F5A;2 H*3L-"B @(" @(" @?0T*(" @(" @("!C871C:" H
    M17AC97!T:6]N(&4I#0H@(" @(" @('L-"B @(" @(" @(" @('1H<F]W(&YE
    M=R!*1$]%>&-E<'1I;VX@*&4N9V5T365S<V%G92 H*2P@92D[#0H@(" @(" @
    M('T-"B @("!]#0H-"B @(" O+R!/<F%C;&4@:7,@<W1R86YG92X@5&AI<R!C
    M;V1E(')E<75I<F5S($I$0D,R+@T*(" @('!U8FQI8R!V;VED(&)L;V)4;U!R
    M97!A<F5D4&%R86UE=&5R("A0<F5P87)E9%-T871E;65N="!S="P@:6YT(&DL
    M( T*(" @(" @("!/8FIE8W0@;RD-"B @(" @(" @=&AR;W=S(%-13$5X8V5P
    M=&EO;@T*(" @('L-"B @(" @(" @3&]G9V5R+F=E=$QO9V=E<BAT:&ES+F=E
    M=$-L87-S*"DI+FEN9F\H(BHJ*B!B;&]B5&]0<F5P87)E9%!A<F%M971E<B Z
    M(B K(&DI.PT*(" @(" @("!I9B H;R ]/2!N=6QL*0T*(" @(" @("![#0H@
    M(" @(" @(" @(" O+R%S="YS971";&]B("AI+"!O<F%C;&4N<W%L+D),3T(N
    M96UP='E?;&]B("@I*3L-"B @(" @(" @(" @('-U<&5R+F)L;V)4;U!R97!A
    M<F5D4&%R86UE=&5R*'-T+"!I+"!O*3L-"B @(" @(" @?0T*(" @(" @("!E
    M;'-E#0H@(" @(" @('L-"B @(" @(" @(" @($]B:F5C="!B;&(@/2!B;&]B
    M5&]344P@*&\I.PT*(" @(" @(" @(" @:68@*&)L8BYE<75A;',@*$5-4%19
    M7T),3T)?4U1224Y'*2D-"B @(" @(" @(" @('L-"B @(" @(" @(" @(" @
    M("!S="YS971";&]B("AI+"!O<F%C;&4N<W%L+D),3T(N96UP='E?;&]B("@I
    M*3L-"B @(" @(" @(" @('T-"B @(" @(" @(" @(&5L<V4-"B @(" @(" @
    M(" @('L-"B @(" @(" @(" @(" @(" O+R!N;W0@<W5R92!W:&5N($D@=VEL
    M;"!G970@:&5R92XN+BXN#0H@(" @(" @(" @(" @(" @=&AR;W<@;F5W(%)U
    M;G1I;65%>&-E<'1I;VXH(E=H>2!D:60@22!G970@:&5R93\B*3L-"B\O(" @
    M(" @(" @(" @(" @("\O(6)Y=&5;72!B;&]B0GET97,@/2 H8GET95M=*2!S
    M=7!E<BYB;&]B5&]344P@*&\I.PT*+R\@(" @(" @(" @(" @(" @8GET95M=
    M(&)L;V)">71E<R ]('LP+#$L,GT[#0HO+R @(" @(" @(" @(" @("!O<F%C
    M;&4N<W%L+D),3T(@9&)";&]B(#T@;F5W(&]R86-L92YS<6PN0DQ/0B H#0HO
    M+R @(" @(" @(" @(" @(" @(" @*&]R86-L92YJ9&)C+D]R86-L94-O;FYE
    M8W1I;VXI<W0N9V5T0V]N;F5C=&EO;B H*2P@#0HO+R @(" @(" @(" @(" @
    M(" @(" @8FQO8D)Y=&5S*3L-"B\O(" @(" @(" @(" @(" @('-T+G-E=$)L
    M;V(@*&DL("A";&]B*2!D8D)L;V(N=&]*9&)C("@I*3L-"B @(" @(" @(" @
    M('T-"B @(" @(" @?0T*(" @('T-"@T*(" @( T*(" @('!U8FQI8R!#;&%S
    M<UM=(&=E=$9I96QD36%P<&EN9T-A;F1I9&%T94-L87-S97,@*"D-"B @("![
    M#0H@(" @(" @(&EF("A?9FEE;&1#;&%S<V5S(#T](&YU;&PI#0H@(" @(" @
    M('L-"B @(" @(" @(" @($-L87-S6UT@<W5P97)#;&%S<V5S(#T@<W5P97(N
    M9V5T1FEE;&1-87!P:6YG0V%N9&ED871E0VQA<W-E<R H*3L-"B @(" @(" @
    M(" @(%]F:65L9$-L87-S97,@/2!N97<@0VQA<W-;<W5P97)#;&%S<V5S+FQE
    M;F=T:%T[#0H@(" @(" @(" @("!3=')I;F<@8VQA<W-.86UE.PT*(" @(" @
    M(" @(" @9F]R("AI;G0@:2 ](# [(&D@/"!?9FEE;&1#;&%S<V5S+FQE;F=T
    M:#L@:2LK*0T*(" @(" @(" @(" @>PT*(" @(" @(" @(" @(" @(&-L87-S
    M3F%M92 ]('-U<&5R0VQA<W-E<UMI72YG971.86UE("@I.PT*(" @(" @(" @
    M(" @(" @(&EF("AC;&%S<TYA;64N97%U86QS("A";&]B36%P<&EN9RYC;&%S
    M<RYG971.86UE("@I*2D-"B @(" @(" @(" @(" @("![#0H@(" @(" @(" @
    M(" @(" @(" @("\O(2$A($D@;F5E9"!A(&-U<W1O;2!C;&%S<R!H97)E#0H@
    M(" @(" @(" @(" @(" @(" @(%]F:65L9$-L87-S97-;:5T@/2!/<F%C;&5"
    M;&]B36%P<&EN9RYC;&%S<SL-"B @(" @(" @(" @(" @("!]#0H@(" @(" @
    M(" @(" @(" @96QS92!I9B H8VQA<W-.86UE+F5Q=6%L<R -"B @(" @(" @
    M(" @(" @(" @(" @(" @(" H17AP;&EC:71";&]B36%P<&EN9RYC;&%S<RYG
    M971.86UE("@I*2D-"B @(" @(" @(" @(" @("![#0H@(" @(" @(" @(" @
    M(" @(" @("\O(2$A($D@;F5E9"!A(&-U<W1O;2!C;&%S<R!H97)E#0H@(" @
    M(" @(" @(" @(" @(" @(%]F:65L9$-L87-S97-;:5T@/2!%>'!L:6-I=$]R
    M86-L94)L;V)-87!P:6YG+F-L87-S.PT*(" @(" @(" @(" @(" @('T-"B @
    M(" @(" @(" @(" @("!E;'-E#0H@(" @(" @(" @(" @(" @>PT*(" @(" @
    M(" @(" @(" @(" @("!?9FEE;&1#;&%S<V5S6VE=(#T@<W5P97)#;&%S<V5S
    M6VE=.PT*(" @(" @(" @(" @(" @('T-"B @(" @(" @(" @('T-"B @(" @
    M(" @?0T*(" @(" @("!R971U<FX@7V9I96QD0VQA<W-E<SL-"B @("!]#0H@
    ((" @#0I]#0H`
    `
    end

  • Problem w/ image item using 9i BLOB field and InterMedia ORDImage Object

    Hi,dear all,
    I have a problem with image item in Form 6i. Oracle 9i is used as backend DB, and a table contains image data is created for testing:
    create table image_test(
    id number,
    image blob
    In Form 6i, there is no problem to create a block for inserting/updating the image record into the database. However, it can not be used to retrieve image (blob field), the image item remains empty after 'execute query', while the id field can be retrieved. When the same table is created in Oracle 8.1.7, and the exact same form can be used without any problem both in inserting and retrieval. It seems that the Oracle 9i does not use the same way to store BLOB column. Has anybody ever encountered this problem? How to retrieve image (BLOB) in Form 6i from Oracle 9i?
    I tried to use interMedia ORDImage as the data type in Oracle 9i, that is,
    create table image_test(
    id number,
    image ORDSYS.ORDImage
    Same problem, the form can insert record with image, but when retrieving, nothing displayed. Anybody could help! Thanks in advance!

    hi!
    well working with oracle8i and form6i.
    same problem..but i used (instead of blob or clob as datatype..) Long raw..
    it can be saved as usual..i mean Commit..
    and can be retrieved..using Execute_Query..its working fine..
    well if anybody get any other solution..do inform..
    mail_id:
    [email protected]

  • Display blob field image in Oracle Express

    Hi,
    I upgraded the apex in my Oracle express edition to 3.2 and tried to display image in blob field following the step in the Apex tutorial,
    but the error '*The requested operation is not allowed* ' prompt.
    I save the image file in a table with fields mime1,picture1=> blob field.
    I created a problem as follow:
    CREATE OR REPLACE PROCEDURE download_my_file(p_hotel_id in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
    --execute immediate
    --'SELECT MIME_TYPE'||to_char(p_picture)||', picture'||to_char(p_picture)||', '||to_char(p_picture)||',DBMS_LOB.GETLENGTH(blob_content) '||
    --'INTO v_mime,lob_loc,v_file_name,v_length FROM hotels_pic '||
    --'WHERE hotel_id = '||to_char(p_hotel_id);
    select mime_type1,picture1,'test/picture1',DBMS_LOB.GETLENGTH(picture1)
    INTO v_mime,lob_loc,v_file_name,v_length
    from hotels_pic where hotel_id=1;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'),FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment;
    filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    GRANT EXECUTE ON download_my_file TO apex_PUBLIC_user;
    GRANT EXECUTE ON download_my_file TO public;
    I tried display the image by using <img src="#OWNER#.download_my_file?p_hotel_id=1" height=60 width=40 /img>
    But the image don't display...
    if I type http://127.0.0.1:8080/apex/HOTEL.download_my_file?p_hotel_id=1 to display the picture , the error " Forbidden,The requested operation is not allowed" prompt.
    Am I miss out anything? Anyone can help?
    Thanks
    Vincent

    Hi,
    I use a slightly difference code to display images: [http://apex.oracle.com/pls/otn/f?p=267:11]
    It is possible that your GRANT command needs to be for PUBLIC instead of public - some things are case-sensitive.
    Also, have you checked in SQL Workshop, Object Browser, Procedures to see if your procedure is valid?
    Andy

  • Error while trying to store PDF in Oracle's BLOB field

    Hi folks!
    I'm having problems while trying to store PDF file in a BLOB field of an Oracle table
    This is the message code:
    Exception in thread "main" java.sql.SQLException: Data size bigger than max size for this type: 169894
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:95)
    at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2414)
    at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1134)
    at oracle.jdbc.driver.OraclePreparedStatement.setBytes(OraclePreparedStatement.java:2170)
    at vgoactualizacion.Main.main(Main.java:84)     
    This is the piece of code i'm using:
    Assuming conn = conection to Oracle 10g Database ( it's working )
    String miProcedimientoAlmacenado = "{ call package_name.update_client(?,?, ?) }";
    CallableStatement miComando = conn.prepareCall(miProcedimientoAlmacenado);
    miComando.setString(1,miClienteID ); //first parameter : IN
                   //second parameter : IN
    File miPDF = new File(pathPDF + "//" + miClienteID + ".pdf");
    byte[] bodyIn = readFully(miPDF); //readFully procedure is shown below
    miComando.setBytes(2, bodyIn); //THIS IS THE LINE WHERE THE ERROR IS PRODUCED
              //3rd parameter: OUT
    miComando.registerOutParameter(3, java.sql.Types.VARCHAR);
    miComando.execute();
    private static byte[] readFully(File miPDF) throws FileNotFoundException, IOException {
    FileInputStream fis = new FileInputStream(miPDF);
    byte[] tmp = new byte[1024];
    byte[] data = null;
    int sz, len = 0;
    while ((sz = fis.read(tmp)) != -1) {
    if (data == null) {
    len = sz;
    data = tmp;
    } else {
    byte[] narr;
    int nlen;
    nlen = len + sz;
    narr = new byte[nlen];
    System.arraycopy(data, 0, narr, 0, len);
    System.arraycopy(tmp, 0, narr, len, sz);
    data = narr;
    len = nlen;
    if (len != data.length) {
    byte[] narr = new byte[len];
    System.arraycopy(data, 0, narr, 0, len);
    data = narr;
    return data;
    }//fin readFully
    This approach indicates that the PDF file is converted into an array of bytes, then is stored as binary in the BLOB field.
    Thanx in advance, and looking forward for your comments.

    You will probably need to use the setBinaryStream() method instead of setBytes().

  • Oracle error ORA-01461when trying to insert into an ORACLE BLOB field

    I am getting Oracle error ‘ORA-01461: can bind a LONG value only  for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
    BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
    ORACLE version is 11.2.0.1
    The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
    Here is my code:
    <cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
    <cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
    <cfset file_mime = 'data:image/' & file_mime & ';base64,'>
    <cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
    <cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
    <cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
    <cffile action="readbinary" file="#ramfile#" variable="image_bin">
    <cffile action="delete" file="#ramfile#">
    <cfquery name="InsertImage" datasource="#datasource#">
    INSERT INTO test_images
    image_blob
    SELECT
    <cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
    FROM          dual
    </cfquery>

    Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.

  • How to upload size 4k file to oracle BLOB field

    hi all, i'm using Oracle 9i, Orcale JDBC thin Driver and ibm websphere to develop a java application.i have used java EJB/CMP to insert images into BLOB field in oracle.
    i used byte[] mapping to BLOB.i did it successfully.
    however, i'm facing another problem. it is that
    when i insert files larger than 4k, there is exception error. it said that the inserted value is too large.
    is that the problem of orcale JDBC?
    is that any solution to solve this restriction?
    it is very urgent, pls help!
    thx a lot

    Hi Lee
    Thanks for ur valuable suggestions. Please give me
    more idea i would really thank to u !Which part is giving you troubles?
    Oh - and change my suggestion to use setBinaryStream to a suggestion to use setAsciiStream, as I missed the part where you said "text file".
    >
    Can anybody tell me anyother way how to solv thid
    problem
    Depending on the size of the text file you could just read the file so you have the contents as a String and use setString (also in the PreparedStatement interface).
    hanks
    Message was edited by:
    MerlinRosina

  • Problem with Pro*C reading BLOB field from Oracle 10g

    Hello Experts,
    We have a Pro*c application which is reading the BLOB data fields (a PNG image file) from Oracle data base. It holds the BLOB fields returned from the SQL query into a Unsigned Char structure in Pro*C. The program used work fine on AIX 32 – bit 4.3 and Oracle 8.1 environment.
    Recently, we have upgraded the environment to AIX 64-bit 5.3 and Oracle 10g.Since after the Pro*c program has problem in reading the Blob filed.
    Below is the query we are trying to execute –
    EXEC SQL
    SELECT
    signtre_image, image_file_name_ext
    INTO
    :msipLocalImage INDICATOR :msipLocalImage_i,
    :file_name_ext INDICATOR :file_name_ext_i
    FROM
    dcs_sign
    WHERE
    signtre_nbr = :signtre_nbr;
    Here signtre_image is the BLOB fields and msipLocalImage is a Pro*C structure define as below –
    typedef struct tagSignImage
    long len; /* Image length */
    unsigned char img[1]; /* Pointer to first byte. */
    } MOTS_SIGN_IMAGE;
    The quesry does not give any error or exception message in the Pro*C , program just stops at the point of executing the quesry..When we run the query commenting the BLOB filed it works fine. Also, the query runs good when we run it in the Oracle editor.
    There seems to be problem with the way we are reading the BLOB field in the new Oracle 10g enviromet.
    Does any body have any idea what’s wrong with this query? We really need it to work.
    Any Help will be greatly appreciated.
    Thanks,
    - Rajan Yadav

    Thanks a ton for your response.
    We made the necessary changes as suggested by you.This time we got another flavour of error - SQL Error Code - Inconsistent error while reading BLOB.
    Another thing we noticed is that the data field which we are trying to read is defined as LONG RAW instead of a BLOB in data base.
    Are these two things related in any sense or is there anything else which is causing the error.
    Once again Thanks for your help.
    - Rajan Yadav

Maybe you are looking for