View Full Version : OCI, how to detect a no_data_found with an update
José Delfosse
06-09-2004, 01:17 PM
Hi,
I have a C++ application developed on IBM AIX 4.3.3 with Oracle 8.1.7.4 that
use OCI to access the database.
I have a loop on an update-statement that update different rows in a table.
During the loop, it might happen that a row is not to be updated because it
does not exist.
After each OCIStmtExecute(), I call the OCIAttrGet() APÏ to retrieve the
OCI_ATTR_ROW_COUNT attribute in order to know
how many rows were updated (I expected one or zero in my case). My goal is
to detect which rows were not updated (because they don't exist).
While it returns 0 before the first OCIStmtExecute() , I found out that this
attribute thereafter always return 1 even if the update found no rows.
Moreover, OCIStmtExecute() returns OCI_SUCCESS even when the update found no
rows.
In fact, the OCI_ATTR_ROW_COUNT seems to work fine only with
fetch-statement.
So, using OCI, does anyone know how to detect that an update statement
found no rows ?
(just like the WHEN NO_DATA_FOUND of Pro*C or PL/SQL)
Many thanks to any experts willing to answer me.
JD
Olivier Guyot
06-13-2004, 11:20 PM
Hello José,
I am not aware of the OCI driver but I can tell you that with the thin
JDBC driver it is easy.
The fact is that with the Jdbc driver you have to use another method :
stmt.executeUpdate(SStmt) instead of the classic stmt.execute(SStmt).
Then the executeUpdate returns the number of updated rows.
Regs,
Olivier Guyot
MyLounge.com Site Map
Forum:
Cars,
Cell Phone,
Database,
Games,
Home Improvement,
IT,
Music,
School,
Sports,
Web Design,
Web Server,
Weight Loss
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service
vBulletin v3.0.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.