Re: pro* C conversion from LONG to BLOBs

From: (wrong string) äth <matthias.spaeth_at_optimum-gmbh.de>
Date: Mon, 31 May 1999 08:45:26 +0200
Message-ID: <7itb09$1vsg$1_at_news.karlsruhe.punkt.de>


Hi Paul,

The following sample writes binary data stored in (char* arr) with a known length (size) to a BLOB-column (data) in a table (tab). You can read the BLOB-value by using the EXEC SQL LOB READ statement at the same way.




OCIBlobLocator *blob;
typedef struct myRawType
{
  long len;
  unsigned char arr[32000];
} myRaw;

EXEC SQL TYPE myRaw IS LONG VARRAW(32000); myRaw buffer;
long size;
int amt;

EXEC SQL ALLOCATE :blob;

EXEC SQL INSERT INTO tab VALUES (EMPTY_BLOB()) RETURNING data INTO :blob;

for (;size>0;size-=32000,ptr+=32000)
{
  amt=size>32000?32000:size;
  memmove(buffer.arr,ptr,amt);
  buffer.len=amt;

  EXEC SQL LOB WRITE APPEND :amt FROM :buffer INTO :blob; }

EXEC SQL COMMIT;
EXEC SQL FREE :blob;



Hope this helps.

Regards.
Matthias
http://www.optimum-gmbh.de

pauldb schrieb in Nachricht <927897950.27214_at_www.remarq.com>...
>
>I am busy trying to do replication of a database using the
>snaphot mechanism that is available under Oracle 8.
>
>However LONGs are not supported for replication and
>so i would like to know if there is anyone who has
>implemented BLOBs.. and can give me any examples of
>reading and writing BLob columns to a table.
>
>I would appreciate any feedback
>
>Thanks,
>Paul
>
>
>
>
>
>
>
>
>**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here
(tm) **** Received on Mon May 31 1999 - 08:45:26 CEST

Original text of this message