Reports the row number and buffer of the row that is currently being updated in the database. When called because of an error, GetUpdateStatus reports the row that caused the error.
Obsolete method GetUpdateStatus is obsolete and will be discontinued in a future release. You should replace all references to GetUpdateStatus as soon as possible. The update status is available as an argument in the DBError and SQLPreview events.
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control, DataWindowChild object |
integer dwcontrol.GetUpdateStatus (long row, DWBuffer dwbuffer )
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control or child DataWindow. |
row |
A variable that will store the number of the row that will be updated or for which an update was attempted. |
dwbuffer |
A value of the dwBuffer enumerated datatype identifying the DataWindow buffer that contains the row being updated. For a list of valid values, see DWBuffer. |
Returns 1 if it succeeds and –1 if an error occurs. The number and buffer of the row currently being updated are stored in row and dwbuffer.
If any argument value is null, the method returns null.
These statements in the script for the DBError event for a DataWindow control obtain the text of the error message, display a message box with the number of the row in which the error occurred and the error message, and then make the row with the error the current row.
Additional code in the IF statement considers the case of the bad row being in the filter or delete buffer. If the row is in the filter buffer, the script changes the filter so that the user can edit the row in the primary buffer. If the row is in the delete buffer, the message box displays a slightly different title:
long row_number, row_key
dwBuffer buffer_type
string message_text, message_title, old_filter
// Get the error message text and set the title
message_text = DBErrorMessage()
message_title = "Database Error Updating Row"
// Get the row in which the error occurred
This.GetUpdateStatus(row_number, buffer_type)
IF buffer_type = Filter! THEN
old_filter = This.Describe("DataWindow.Filter")
row_key = This.GetItemNumber(row_number, &
"emp_id", Filter!, false)
This.SetFilter("(" + old_filter + ")" + &
"OR emp_id = " + String(row_key))
This.Filter()
// Error row is now last row in primary buffer
row_number = This.RowCount()
ELSEIF buffer_type = Delete! THEN
message_title = "Database Error Deleting Row"
END IF
// Display the location of the error and the error
// message.
MessageBox(message_title + &
String(row_number), message_text)
IF buffer_type <> Delete! THEN
// Make the row with the error the current row.
This.ScrollToRow(row_number)
END IF
// Return 1 from the DBError event
// (do not display error message) because we've
// already displayed a message
RETURN 1