Four buffers of DataWindow
In PowerBuilder, DataWindow is the object that the user front-end uses to store and manipulate data. In each DataWindow object, 4 two-dimensional tables are used as data buffers to store the data that is queried. In the DataWindow, the operation of the data processing system in the user is actually the modification and movement of it in these buffers, finally, when the user submits the database, the system forms the SQL in-sert,update,delete and so on according to the information in these four buffers. These four buffers are:
1, Primary Buffer
This buffer is the one that holds the data in the DataWindow control in the Fill window, and the retrieve () function and InsertRow () function that calls DataWindow can populate the buffer with the data. When you use the About DataWindow Delete and filter functions, the corresponding records are removed from this buffer. When the DataWindow update () function is executed, PowerBuilder will look at the records in this buffer to form the SQL INSERT and UPDATE statements.
2, Delete Buffer
This buffer holds records that are deleted from primary buffer using the DeleteRow () function, and the system creates a DELETE statement based on the record of the buffer when the update () function is executed.
3. Filter Buffer
This buffer stores the remaining records from original buffer using the filter () function to filter into the primary buffer.
4, Original Buffer
This buffer stores all of the records that were obtained when DataWindow first executed the retrieve () function. When the database is submitted, the UPDATE statement generated from the primary buffer and the DELETE statement generated from the delete buffer are based on this buffer to construct the WHERE clause in these SQL statements.
The Original buffer is maintained internally by PowerBuilder, and any function provided by Power-builder cannot change its value, but the getitem provided by PowerBuilder ... The function of the series can read out the original values that DataWindow originally found from the database. These functions allow us to programmatically implement the so-called "Undo" function and get a WHERE clause that forms the submitting database when using optimistic locks.
If the DataWindow you are currently using does not have the right to modify, you will not be able to operate on the delete buffer and the original buffer and will cause a system error when calling Update ().
The state value of the data buffer
Both the Primary buffer and the delete buffer have a row-level and column-level state value, which is an enumeration type. The state value of the line at the time of submission determines whether the SQL statement is to be generated, where primary buffer produces the In-sert and UPDATE statements, and the delete buffer produces the DELETE statement. We can manipulate this state value using the Getitemstatus () function and the Setitemstatus () function. This enumeration state has the following four kinds:
· Notmodified!——— The value of the row or row is the result of the query and has not changed.
· Datamodified!——— The value of the row or column is the result of the query, which has changed.
· New!——— the row or column as a newly inserted row, the data has not changed (the data is blank or the default value).
· Newmodified!——— the row or column as a new row inserted, the data changes. Change is the SetItem () function that is entered or invoked through the user's keyboard.