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.

Executing SQL Queries<br />

Result Set<br />

Execution of a database query puts the results of the query into a set of rows called<br />

the result set. In OCCI, a SQL SELECT statement is executed by the executeQuery<br />

method of the Statement class. This method returns an ResultSet object that<br />

represents the results of a query.<br />

ResultSet *rs = stmt->executeQuery("SELECT * FROM basket_tab");<br />

Once you have the data in the result set, you can perform operations on it. For<br />

example, suppose you wanted to print the contents of this table. The next method<br />

of the ResultSet is used to fetch data, and the getxxx methods are used to<br />

retrieve the individual columns of the result set, as shown in the following code<br />

example:<br />

cout getString(1); // get the first column as string<br />

int quantity = rs->getInt(2); // get the second column as int<br />

}<br />

cout

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

Saved successfully!

Ooh no, something went wrong!