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.

Overview of <strong>Oracle</strong> Datatypes<br />

Overview of <strong>Oracle</strong> Datatypes<br />

Accurate communication between your <strong>C++</strong> program and the <strong>Oracle</strong> database<br />

server is critical. OCCI applications can retrieve data from database tables by using<br />

SQL queries or they can modify existing data through the use of SQL INSERT,<br />

UPDATE, and DELETE functions. To facilitate communication between the host<br />

language <strong>C++</strong> and the database server, you must be aware of how <strong>C++</strong> datatypes<br />

are converted to <strong>Oracle</strong> datatypes and back again.<br />

In the <strong>Oracle</strong> database, values are stored in columns in tables. Internally, <strong>Oracle</strong><br />

represents data in particular formats called internal datatypes. NUMBER, VARCHAR2,<br />

and DATE are examples of <strong>Oracle</strong> internal datatypes.<br />

OCCI applications work with host language datatypes, or external datatypes,<br />

predefined by the host language. When data is transferred between an OCCI<br />

application and the database server, the data from the database is converted from<br />

internal datatypes to external datatypes.<br />

OCCI Type and Data Conversion<br />

OCCI defines an enumerator called Type that lists the possible data representation<br />

formats available in an OCCI application. These representation formats are called<br />

external datatypes. When data is sent to the database server from the OCCI<br />

application, the external datatype indicates to the database server what format to<br />

expect the data. When data is requested from the database server by the OCCI<br />

application, the external datatype indicates the format of the data to be returned.<br />

For example, on retrieving a value from a NUMBER column, the program may be set<br />

to retrieve it in OCCIINT format (a signed integer format into an integer variable).<br />

Or, the client might be set to send data in OCCIFLOAT format (floating-point<br />

format) stored in a <strong>C++</strong> float variable to be inserted in a column of NUMBER type.<br />

An OCCI application binds input parameters to a Statement, by calling a setxxx<br />

method (the external datatype is implicitly specified by the method name), or by<br />

calling the registerOutParam, setDataBuffer, or setDataBufferArray<br />

method (the external datatype is explicitly specified in the method call). Similarly,<br />

when data values are fetched through a ResultSet object, the external<br />

representation of the retrieved data must be specified. This is done by calling a<br />

getxxx method (the external datatype is implicitly specified by the method name)<br />

or by calling the setDataBuffer method (the external datatype is explicitly<br />

specified in the method call).<br />

4-2 <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!