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.

Status Definitions<br />

Executing Statements Dynamically<br />

Statement stmt = conn->createStatement();<br />

Statement::Status status = stmt->status(); // status is UNPREPARED<br />

stmt->setSQL("select * from emp");<br />

status = stmt->status(); // status is PREPARED<br />

If a statement handle is created with a SQL string, then it is created in a PREPARED<br />

state. For example:<br />

Statement stmt = conn->createStatement("insert into foo(id) values(99)");<br />

Statement::Status status = stmt->status(); // status is PREPARED<br />

status = stmt->execute(); // status is UPDATE_COUNT_AVAILABLE<br />

When you set another SQL statement on the Statement, the status changes to<br />

PREPARED. For example:<br />

stmt->setSQL("select * from emp"); // status is PREPARED<br />

status = stmt->execute(); // status is RESULT_SET_AVAILABLE<br />

This section describes the possible values of Status related to a statement handle:<br />

■ UNPREPARED<br />

■ PREPARED<br />

■ RESULT_SET_AVAILABLE<br />

■ UPDATE_COUNT_AVAILABLE<br />

■ NEEDS_STREAM_DATA<br />

■ STREAM_DATA_AVAILABLE<br />

UNPREPARED<br />

If you have not used the setSQL method to attribute a SQL string to a statement<br />

handle, then the statement is in an UNPREPARED state.<br />

Statement stmt = conn->createStatement();<br />

Statement::Status status = stmt->status(); // status is UNPREPARED<br />

PREPARED<br />

If a Statement is created with a SQL string, then it is created in a PREPARED state.<br />

For example:<br />

Statement stmt = conn->createStatement("INSERT INTO demo_tab(id)<br />

Relational Programming 2-17

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

Saved successfully!

Ooh no, something went wrong!