Thursday, March 31, 2011

Detecting the number of ORACLE rows updated by a OCI OCIStmtExecute call

I have an ORACLE update statement that I call using the OCIStmtExecute function call.

Using an OCI function call I would like to know how many rows have been updated by the action, e.g. zero, one or more.

How do I do this ?

From stackoverflow
  • Invoke OCIAttrGet(OCI_ATTR_ROW_COUNT) on the statement handle.

    David : Thanks Quassnoi I'd just worked it out too myself and have posted an answer as well. Thanks for looking at it.
  • Use the OCIAttrGet function call on your OCIStmt statement handle with the attribute type set to OCI_ATTR_ROW_COUNT

    So add the folllowing code to your program :

       ub4 row_count;
    
       rc = OCIAttrGet ( stmthp, OCI_HTYPE_STMT, &row_count, 0, OCI_ATTR_ROW_COUNT,
               errhp );
    

    where:

    stmthp is the OCIStmt statement handle

    errhp is the OCIError error handle

    rc is the defined return code (sword)

    The number of rows updated (or deleted and inserted if that is your operation) is written into the passed row_count variable

0 comments:

Post a Comment