user52800
user52800

Reputation:

Powerbuilder - SQLNRows is 0 after Datawindow update

The first time I call Update on my DataWindow it returns 1 (success) and SQLCA.SQLNRows is 1. When I do a second update on the same screen without closing it in between, Update returns 1 and SQLCA.SQLNRows is 0. Any suggestions why this is happening?

Upvotes: 2

Views: 6212

Answers (3)

Hugh Brackett
Hugh Brackett

Reputation: 2706

Updated answer: You can get the results of the Update in the UpdateEnd event. In that event you have rowsinserted, rowsupdated, and rowsdeleted.

Original answer: A good way to tell what's going on if you're using PFC is to use the SQL Spy service. In a non-PFC app, you could put a do-nothing line like beep(1) in the DataWindow's sqlpreview event, set a breakpoint on that line, and use the debugger to watch what's going on. You could also use the SQL statement trace facility or the Database Trace tool as described in Troubleshooting Your Connection in the Connecting to Your Database book.

Upvotes: 0

Terry
Terry

Reputation: 6215

Your question seems to hit a couple of things.

Firstly, as John Paul mentions, Update() will return 1 even if there are no rows updated. There is no specific return value for "nothing to be done."

Secondly, as mentioned in the help file, the value for SQLNRows is DBMS-dependent, so it's hard to comment on the value being filled in there without knowing the DBMS involved. However, regardless of that, since the DataWindow issues a series of INSERTs, UPDATEs and DELETEs that are targeted at only one row, if this value is populated I wouldn't expect it would ever be more than one, no matter how many SQL statements the DataWindow issues. The number of rows affected for the last SQL statement issued should always be one.

If you're trying to find the number of rows affected by a DataWindow Update(), before the Update(), check the value of ModifiedCount() + DeletedCount().

Good luck,

Terry.

Upvotes: 3

John Paul Jones
John Paul Jones

Reputation: 700

It's been a long time since I've used PB, but isn't the .Update()'s return value simply an indicator of the command (i.e. UPDATE) being successfully performed by the DB? If this is correct then it'll return 1, when successful, even if row values are not actually changing. SqlNRows is the actual indicator of the number of changed rows.

Upvotes: 2

Related Questions