Re: OCI: Write BLOB's

From: Axel Fix <Axel.Fix_at_t-systems.de>
Date: Wed, 12 Dec 2001 09:45:07 +0100
Message-ID: <1008146709.821314_at_blau.b3.dsh.de>


Thank you for your help. I've tried it, but there must be another mistake so it doesn't work
:-(

Axel

"stuart coupe" <stuart_at_easysoft.com> schrieb im Newsbeitrag news:3C15F00B.8070808_at_easysoft.com...
>
> Try using something like :
> insert into foo ( b, c) values ( empty_blob(), :1 ) returning b into :0 ;
>
> This inserts an empty blob and returns the blob handle.
> You can then write to the blob using OCILobWrite and this handle.
>
> It took me a while to work this one out ;)
>
> Hope this helps.
>
> Cheers,
> Stuart.
>
> Axel Fix wrote:
>
> >Hallo,
> >
> >I wrote a class to encapsulate Insert statements and now I want to insert
> >blob's.
> >The statement looks like:
> > insert into foo (b,c) values (:0, :1)
> >where b is a blob column.
> >I have found that if I write the statement like above I have to
initialize
> >the lob locator
> >before I bind it. So I do the following (buffered statement):
> >
> >... // init the blob column
> > ub4 loc_empty = 0;
> > for (c=0;c < row_size;c++)
> > { ....
> > // bei c == 0 -->
> > // set all loc empty
> > for (r=0;r < nrows;r++)
> > { OCIDescriptorAlloc(env, &row[c].blob[r], (ub4)OCI_DTYPE_LOB, 0,
> >NULL);
> > OCIAttrSet(row[c].blob[r], OCI_DTYPE_LOB, &loc_empty,
> >sizeof(loc_empty),
> > OCI_ATTR_LOBEMPTY, error);
> > }
> > OCIBindByPos(hstmt, &row[c].hbnd, error, c+1,
> > &row[c].blob[0], sizeof(void*), row[c].dty,
> > &row[c].nidx[0], NULL, NULL, 0, NULL, OCI_DEFAULT);
> > OCIBindArrayOfStruct(row[c].hbnd, error,(sb4)row[c].size, 0,0,0);
> > }
> >...
> >... // and later I want to write
> >const char* buff = "test test test test test test test test";
> >ub4 amtp;
> >dword bsz, off=1;
> >
> >bsz = amtp = strlen(buff);
> >OCILobWrite(ctx, error, row[c].blob[0], &amtp, off, // I
> >really want to write at blob 0
> > buff, bsz, OCI_ONE_PIECE, NULL, NULL, 0,
> > (ub1)SQLCS_IMPLICIT);
> >
> >But this call return -2 (OCI_INVALID_HANDLE).
> >Where is the problem? I hope somebody can help me.
> >
> >Thanks in advance,
> >Axel
> >
> >
> >
>
Received on Wed Dec 12 2001 - 09:45:07 CET

Original text of this message