StrataFrame Forum

ROWCOUNT Parameter with Oracle SPs

http://forum.strataframe.net/Topic11013.aspx

By Keith Harvey - 8/22/2007

Hi there,

I am using Oracle SPs to handle my Inserts, Updates, etc.  I noticed that I had to have an out parameter named ROWCOUNT in order for my SPs to work.

Does SF use the ROWCOUNT parameter?  Is there a way I can access via my BOs?

Cheers,

Keith

By StrataFrame Team - 8/22/2007

The ROWCOUNT is needed to determine how many rows were modified by the last action.  So, it's either going to contain 1 or 0 so that the BO can check for concurrency issues.  1 means the record was successfully updated, 0 means the record was not updated because it's been deleted, or the concurrency checks failed.  We had to include a ROWCOUNT because silly Oracle does not automatically return the RecordsAffected through the ExecuteNonQuery() on the OracleCommand objects for stored procedures.  So, in order to determine whether the record was updated, we had to include the ROWCOUNT parameter that should return the number of records affected by the command.

Looking at my Oracle unit tests, we use this to stuff the row count into the parameter:

"P_ROWCOUNT" := SQL%ROWCOUNT;

As for only returning a set number of rows... you can certainly use the WHERE ROWCOUNT < X as the equivalent of SQL TOP X.  We do this in places where we need to generate a SELECT TOP dynamically.  But if you want the raw rowcount of the table, you'll just have to use SELECT COUNT(*).