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.

■ executeArrayUpdate: To execute multiple DML statements<br />

Executing SQL DDL and DML Statements<br />

Creating a Database Table<br />

Using the executeUpdate method, the following code example demonstrates how<br />

you can create a database table:<br />

stmt->executeUpdate(“CREATE TABLE basket_tab<br />

(fruit VARCHAR2(30), quantity NUMBER)”);<br />

Inserting Values into a Database Table<br />

Similarly, you can execute a SQL INSERT statement by invoking the<br />

executeUpdate method:<br />

stmt->executeUpdate(“INSERT INTO basket_tab<br />

VALUES(‘MANGOES’, 3)”);<br />

The executeUpdate method returns the number of rows affected by the SQL<br />

statement.<br />

See Also:<br />

Reusing a Statement Handle<br />

■ Appendix A, "OCCI Demonstration Programs" and the code<br />

example occidml.cpp that demonstrates how to perform insert,<br />

select, update, and delete operations of a table row by using<br />

OCCI<br />

You can reuse a statement handle to execute SQL statements multiple times. For<br />

example, to repeatedly execute the same statement with different parameters, you<br />

specify the statement by the setSQL method of the Statement handle:<br />

stmt->setSQL(“INSERT INTO basket_tab VALUES(:1,:2)”);<br />

You may now execute this INSERT statement as many times as required. If at a later<br />

time you wish to execute a different SQL statement, you simply reset the statement<br />

handle. For example:<br />

stmt->setSQL(“SELECT * FROM basket_tab WHERE quantity >= :1”);<br />

Relational Programming 2-7

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

Saved successfully!

Ooh no, something went wrong!