@@ -39,6 +39,7 @@ static PyObject *cxoCursor_var(cxoCursor*, PyObject*, PyObject*);
3939static PyObject * cxoCursor_arrayVar (cxoCursor * , PyObject * );
4040static PyObject * cxoCursor_bindNames (cxoCursor * , PyObject * );
4141static PyObject * cxoCursor_getDescription (cxoCursor * , void * );
42+ static PyObject * cxoCursor_getLastRowid (cxoCursor * , void * );
4243static PyObject * cxoCursor_new (PyTypeObject * , PyObject * , PyObject * );
4344static int cxoCursor_init (cxoCursor * , PyObject * , PyObject * );
4445static PyObject * cxoCursor_repr (cxoCursor * );
@@ -117,6 +118,7 @@ static PyMemberDef cxoCursorMembers[] = {
117118//-----------------------------------------------------------------------------
118119static PyGetSetDef cxoCursorCalcMembers [] = {
119120 { "description" , (getter ) cxoCursor_getDescription , 0 , 0 , 0 },
121+ { "lastrowid" , (getter ) cxoCursor_getLastRowid , 0 , 0 , 0 },
120122 { NULL }
121123};
122124
@@ -608,6 +610,37 @@ static PyObject *cxoCursor_getDescription(cxoCursor *cursor, void *unused)
608610}
609611
610612
613+ //-----------------------------------------------------------------------------
614+ // cxoCursor_getLastRowid()
615+ // Return the rowid of the last modified row if applicable. If no row was
616+ // modified the value None is returned.
617+ //-----------------------------------------------------------------------------
618+ static PyObject * cxoCursor_getLastRowid (cxoCursor * cursor , void * unused )
619+ {
620+ uint32_t rowidStrLength ;
621+ const char * rowidStr ;
622+ dpiRowid * rowid ;
623+
624+ // make sure the cursor is open
625+ if (cxoCursor_isOpen (cursor ) < 0 )
626+ return NULL ;
627+
628+ // get the value, if applicable
629+ if (cursor -> handle ) {
630+ if (dpiStmt_getLastRowid (cursor -> handle , & rowid ) < 0 )
631+ return cxoError_raiseAndReturnNull ();
632+ if (rowid ) {
633+ if (dpiRowid_getStringValue (rowid , & rowidStr , & rowidStrLength ) < 0 )
634+ return cxoError_raiseAndReturnNull ();
635+ return cxoPyString_fromEncodedString (rowidStr , rowidStrLength ,
636+ cursor -> connection -> encodingInfo .encoding , NULL );
637+ }
638+ }
639+
640+ Py_RETURN_NONE ;
641+ }
642+
643+
611644//-----------------------------------------------------------------------------
612645// cxoCursor_close()
613646// Close the cursor. Any action taken on this cursor from this point forward
0 commit comments