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.

OCCI Demonstration Programs<br />

string password;<br />

string url;<br />

void insertRows (Connection *conn)<br />

throw (SQLException)<br />

{<br />

Statement *stmt = conn->createStatement ("INSERT INTO print_media(product_<br />

id,ad_id,ad_composite,ad_sourcetext) VALUES (6666,11001,'10001','SHE')");<br />

stmt->executeUpdate();<br />

stmt->setSQL ("INSERT INTO print_media(product_id,ad_id,ad_composite,ad_<br />

sourcetext) VALUES (7777,11001,'1010','HEM')");<br />

stmt->executeUpdate();<br />

conn->commit();<br />

conn->terminateStatement (stmt);<br />

}<br />

void deleteRows (Connection *conn)<br />

throw (SQLException)<br />

{<br />

Statement *stmt = conn->createStatement ("DELETE print_media WHERE product_<br />

id = 6666 AND ad_id=11001");<br />

stmt->executeUpdate();<br />

stmt->setSQL ("DELETE print_media WHERE product_id = 7777 AND ad_id=11001");<br />

stmt->executeUpdate();<br />

conn->commit();<br />

conn->terminateStatement (stmt);<br />

}<br />

/**<br />

* populating the blob;<br />

*/<br />

void populateBlob (Blob &blob, int size)<br />

throw (SQLException)<br />

{<br />

Stream *outstream = blob.getStream (1,0);<br />

char *buffer = new char[size];<br />

memset (buffer, (char)10, size);<br />

outstream->writeBuffer (buffer, size);<br />

char *c = (char *)"";<br />

outstream->writeLastBuffer (c,0);<br />

delete (buffer);<br />

blob.closeStream (outstream);<br />

A-10 <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!