Re: Blobs in Oracle databases

Maxime LABELLE <[email protected]> Tue, 1 Apr 2003 12:50:43 +0200
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2F83C.8B13AC66
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

All right, guys, I've finally made it!
=20
Thanks to the AOTBLOB sample, I was able to reproduce the steps
and finally solve my problem. For your information here is what went =
wrong:
=20
1. insertion of the record, should be made with a NULL blob contents, =
rather
    than a blob initialized to EMPTY_BLOB()
=20
2. in the bindings, the pObject->dwFlags should be set to STGM_READ,
    contrary to what is explained in the MSDN documentation
=20
3. before opening the Rowset, some properties should be set
    DBPROP_IRowsetChange  =3D TRUE
    DBPROP_UPDATABILITY  =3D DBPROPVAL_UP_CHANGE |
                                               DBPROPVAL_UP_INSERT |
                                               DBPROPVAL_UP_DELETE
=20
Cheers
Maxime.

-----Message d'origine-----
De : OLEDB_DEV [mailto:[email protected]]De la part de =
Maxime
LABELLE
Envoy=E9 : mardi 1 avril 2003 09:20
=C0 : [email protected]
Objet : Re: [OLEDB_DEV] Blobs in Oracle databases


Hi,
=20
I'm using the OraOLEDB.Oracle provider.
=20
Alternatively, I have tried the other way around, that it,
implementing ISequentialStream myself and handing out
and interface pointer to the Rowset, then calling =
IRowsetChange::SetData
=20
This leads to a E_POINTER error.
=20
Cheers.
Maxime.

-----Message d'origine-----
De : OLEDB_DEV [mailto:[email protected]]De la part de Alan
Gamboa
Envoy=E9 : lundi 31 mars 2003 19:55
=C0 : [email protected]
Objet : Re: [OLEDB_DEV] Blobs in Oracle databases


Quick question, which driver are you using MS or Oracle, I have had =
better
luck with the Oracle driver...

-----Original Message-----
From: Maxime LABELLE [mailto:[email protected]]
Sent: Monday, March 31, 2003 10:41 AM
To: [email protected]
Subject: [OLEDB_DEV] Blobs in Oracle databases



Hi all,=20

Has anyone successfully stored blobs in an Oracle table=20
using ISequentialStream. Here is how I have tried it:=20

1. First I insert a new record in the table, with all meaningful=20
    information set, and the blob contents initialized to EMPTY_BLOB(): =

    INSERT INTO MYTABLE (ID, CONTENTS) VALUES (:id, EMPTY_BLOB())=20

2. Then, I select the blob column using an SQL statement.=20
    Before calling IRowset::GetData, I perform the binding=20
    with the appropriate information:=20

    a) wType =3D DBTYPE_UNKNOWN=20
    b) dwPart =3D DBPART_VALUE | DBPART_STATUS=20
    b) pObject->iid =3D __uuidof(ISequentialStream)=20
    c) pObject->dwFlags =3D STGM_WRITE=20

    SELECT CONTENTS FROM MYTABLE WHERE ID =3D :id=20

The GetData call succeeds and I have a valid ISequentialStream=20
pointer. But actually writing the data returns E_FAIL with no=20
precision to what failed whatsoever.=20

I have tried initializing the column to NULL and using dwFlags =3D =
STGM_CREATE

but that doesn't work either.=20

Has anyone some useful tips to share?=20
Cheers.=20
Maxime.=20


You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.=20

You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.=20


You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

------_=_NextPart_001_01C2F83C.8B13AC66
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>Blobs in Oracle databases</TITLE>

<META content=3D"MSHTML 5.00.3315.2870" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>All=20
right, guys, I've finally made it!</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>Thanks=20
to the AOTBLOB sample, I was able to reproduce the =
steps</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>and=20
finally solve my problem. For your information here is what went=20
wrong:</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>1.=20
insertion of the record, should be made with a NULL blob contents,=20
rather</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>&nbsp;&nbsp;&nbsp; than a blob initialized =
to=20
EMPTY_BLOB()</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>2. in=20
the bindings, the pObject-&gt;dwFlags should be set to=20
STGM_READ,</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>&nbsp;&nbsp;&nbsp; contrary to what is =
explained in the=20
MSDN documentation</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D416514110-01042003>3.=20
before opening the Rowset, some properties should be =
set</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>&nbsp;&nbsp;&nbsp; =
DBPROP_IRowsetChange&nbsp; =3D=20
TRUE<BR>&nbsp;&nbsp;&nbsp; DBPROP_UPDATABILITY&nbsp; =
=3D&nbsp;DBPROPVAL_UP_CHANGE=20
|</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
DBPROPVAL_UP_INSERT |</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;DBPROPVAL_UP_DELETE</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>Cheers</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D416514110-01042003>Maxime.</SPAN></FONT></DIV>
<BLOCKQUOTE>
  <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
  size=3D2>-----Message d'origine-----<BR><B>De&nbsp;:</B> OLEDB_DEV=20
  [mailto:[email protected]]<B>De la part de</B> Maxime=20
  LABELLE<BR><B>Envoy=E9&nbsp;:</B> mardi 1 avril 2003 =
09:20<BR><B>=C0&nbsp;:</B>=20
  [email protected]<BR><B>Objet&nbsp;:</B> Re: [OLEDB_DEV] =
Blobs in=20
  Oracle databases<BR><BR></DIV></FONT>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003>Hi,</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D120191707-01042003>I'm=20
  using the OraOLEDB.Oracle provider.</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003>Alternatively, I have tried the other way =
around,=20
  that it,</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003>implementing ISequentialStream myself and =
handing=20
  out</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D120191707-01042003>and=20
  interface pointer to the Rowset, then calling=20
  IRowsetChange::SetData</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D120191707-01042003>This=20
  leads to a E_POINTER error.</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003>Cheers.</SPAN></FONT></DIV>
  <DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
  class=3D120191707-01042003>Maxime.</SPAN></FONT></DIV>
  <BLOCKQUOTE>
    <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
    size=3D2>-----Message d'origine-----<BR><B>De&nbsp;:</B> OLEDB_DEV=20
    [mailto:[email protected]]<B>De la part de</B> Alan=20
    Gamboa<BR><B>Envoy=E9&nbsp;:</B> lundi 31 mars 2003 =
19:55<BR><B>=C0&nbsp;:</B>=20
    [email protected]<BR><B>Objet&nbsp;:</B> Re: =
[OLEDB_DEV] Blobs=20
    in Oracle databases<BR><BR></DIV></FONT>
    <DIV><SPAN class=3D359290118-31032003><FONT color=3D#0000ff =
face=3DArial=20
    size=3D2>Quick question, which driver are you using MS or Oracle, I =
have had=20
    better luck with the Oracle driver...</FONT></SPAN></DIV>
    <BLOCKQUOTE>
      <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
      size=3D2>-----Original Message-----<BR><B>From:</B> Maxime =
LABELLE=20
      [mailto:[email protected]]<BR><B>Sent:</B> Monday, March 31, 2003 =
10:41=20
      AM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> =

      [OLEDB_DEV] Blobs in Oracle databases<BR><BR></FONT></DIV>
      <P><FONT face=3DArial size=3D2>Hi all,</FONT> </P>
      <P><FONT face=3DArial size=3D2>Has anyone successfully stored =
blobs in an=20
      Oracle table</FONT> <BR><FONT face=3DArial size=3D2>using =
ISequentialStream.=20
      Here is how I have tried it:</FONT> </P>
      <P><FONT face=3DArial size=3D2>1. First I insert a new record in =
the table,=20
      with all meaningful</FONT> <BR><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;=20
      information set, and the blob contents initialized to =
EMPTY_BLOB():</FONT>=20
      <BR><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; INSERT INTO =
MYTABLE (ID,=20
      CONTENTS) VALUES (:id, EMPTY_BLOB())</FONT> </P>
      <P><FONT face=3DArial size=3D2>2. Then, I select the blob column =
using an SQL=20
      statement.</FONT> <BR><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp; Before=20
      calling IRowset::GetData, I perform the binding</FONT> <BR><FONT=20
      face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; with the appropriate=20
      information:</FONT> </P>
      <P><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; a) wType =3D=20
      DBTYPE_UNKNOWN</FONT> <BR><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp; b)=20
      dwPart =3D DBPART_VALUE | DBPART_STATUS</FONT> <BR><FONT =
face=3DArial=20
      size=3D2>&nbsp;&nbsp;&nbsp; b) pObject-&gt;iid =3D =
__uuidof(ISequentialStream)=20
      </FONT><BR><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; c)=20
      pObject-&gt;dwFlags =3D STGM_WRITE</FONT> </P>
      <P><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; SELECT CONTENTS =
FROM MYTABLE=20
      WHERE ID =3D :id</FONT> </P>
      <P><FONT face=3DArial size=3D2>The GetData call succeeds and I =
have a valid=20
      ISequentialStream</FONT> <BR><FONT face=3DArial size=3D2>pointer. =
But actually=20
      writing the data returns E_FAIL with no</FONT> <BR><FONT =
face=3DArial=20
      size=3D2>precision to what failed whatsoever.</FONT> </P>
      <P><FONT face=3DArial size=3D2>I have tried initializing the =
column to NULL=20
      and using dwFlags =3D STGM_CREATE</FONT> <BR><FONT face=3DArial =
size=3D2>but=20
      that doesn't work either.</FONT> </P>
      <P><FONT face=3DArial size=3D2>Has anyone some useful tips to =
share?</FONT>=20
      <BR><FONT face=3DArial size=3D2>Cheers.</FONT> <BR><FONT =
face=3DArial=20
      size=3D2>Maxime.</FONT> </P><BR>You can read messages from the =
OLEDB_DEV=20
      archive, unsubscribe from OLEDB_DEV, or subscribe to other =
DevelopMentor=20
      lists at http://discuss.develop.com.</BLOCKQUOTE>You can read =
messages from=20
    the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to =
other=20
    DevelopMentor lists at http://discuss.develop.com. </BLOCKQUOTE>You =
can read=20
  messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or =
subscribe=20
  to other DevelopMentor lists at http://discuss.develop.com.=20
</BLOCKQUOTE></BODY></HTML>
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

------_=_NextPart_001_01C2F83C.8B13AC66--