10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Objects with LOB Attributes<br />

conn->commit();<br />

The following code example demonstrates how to update a BFILE:<br />

Bfile bfile(conn);<br />

bfile.setName("MEDIA_DIR", "img1.jpg");<br />

stmt->setSQL("UPDATE print_media SET ad_graphic = :1<br />

WHERE product_id=6666");<br />

stmt->setBfile(1, bfile);<br />

stmt->executeUpdate();<br />

conn->commit();<br />

Objects with LOB Attributes<br />

An OCCI application can use the overloaded operator new() to create a persistent<br />

or transient object with a LOB attribute. By default, all LOB attributes are<br />

constructed by using the default constructor and initialized to null.<br />

Persistent Objects with LOB Attributes<br />

It is possible to use OCCI to create a new persistent object with a LOB attribute. To<br />

do so, follow these steps:<br />

1. Create a persistent object with a LOB attribute.<br />

Person *p=new(conn,"PERSON_TAB")Person();<br />

2. Initialize the Blob object to empty.<br />

p->imgBlob = Blob(conn);<br />

p->imgBlob.setEmpty();<br />

If appropriate, then use the corresponding methods (setxxx methods and<br />

getxxx methods) on the Person object to accomplish the same thing.<br />

3. Mark the Blob object as dirty.<br />

p->markModified();<br />

4. Flush the object.<br />

p->flush();<br />

5-16 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!