DataWindow data buffer

zhaozj2021-02-17  65

DataWindow's data buffer Zhang Jianzi 01-6-22 03:14:44

Four bufts of DataWindow

In PowerBuilder, DataWindow is an object that is used to store and manipulate data. There are 4 two-dimensional tables in each DataWindow object as the data buffer to store queried data. The operations inside the data processing system in DataWindow are actually modified and moved in these buffers, and finally, when the user submits the database, the system forms SQL according to the information in the four buffers. IN-SERT, UPDATE, DELETE and other statements. These four buffers are:

Primary buffer

This buffer is data in the DataWindow control in the stored population, and the database () function that calls DataWindow can fill the data in this buffer. When using the DataWindOW delete and filtering function, the corresponding record will be removed from this buffer. When executing the DataWindow's Update () function, PowerBuilder will view records in this buffer to form SQL INSERT and UPDATE statements.

Delete buffer

This buffer saves records that use the deleterow () function from the Primary Buffer to execute the Update () function, the system forms the DELETE statement based on the record of this buffer.

Filter Buffer

This buffer is stored from ORIGINAL BUFFER to filter into the remaining records after the Primary Buffer.

Original Buffer

This buffer stores all records obtained when DataWindow initially executes the Retrieve () function. When submitting the database, the Update statement generated according to the Primary Buffer and the delete statement generated according to the Delete Buffer are constructed in this buffer to construct the WHERE clauses in these SQL statements.

Original Buffer is maintained by PowerBuilder, any function provided by Power-Builder cannot change its value, but the GetItem ... series of function provided by PowerBuilder can read the original value of DataWindow from the database. Through these functions we can program the so-called "undo" function, and get the WHERE clause that forms the submission database when using the optimistic lock.

If your current DataWindow does not set the modified power, you will not be able to operate the DELETE buffer and the Original buffer, and the system error will also be caused when Update () is called.

Data buffer status value

Both PRIMARY BUFFER and DELETE BUFFER have a status value of the rank and column, which is an enumeration type. The status value of the line is determined if the status value of the line is to generate a SQL statement, where the primary buffer generates an In-SERT and UPDATE statement, while the delete buffer is the delete statement. We use the GetItemStatus () function and the setItemStatus () function to operate on this status value. This enumerated state has the following four:

· NOTMODIFIED! --- The value of the line or row is query, and there is no change.

· DataModified! --- The value of the row or column is the query, there has been a change.

· New! --- This row or a new line of the insertion, the data does not change (the data is empty or default).

· NewModified! --- This row or a new row listed as an insert, the data changes. The change is entered by the user keyboard or called the setItem () function.

Let us look at the example below:

We have such a table, there are three fields in the table, where Item is the primary key.

Item char (5);

Name char (20);

Quantity Int.

In Script we query this table record, get the following information stored in Primary and Origianal Buffer, the line number is the buffer plus. ! Tb 01175000.gif

In the window, we have programmed the number of rows that are 0 and plus an empty line:

dw_1.setfilter ("Quantity = 0")

dw_1.filter ()

Dw_1.inSertrow () At this time, the status of Primary Buffers is:! TB 01175001.gif

Records in Filter Buffer are:! TB 01175002.gif

The user enters data in the new line to delete line 3 data and modify the second line of data. When he leaves this DataWindow, the status of the Primary and the Delete buffer are as follows :! TB 01175003.gif

The DW_1.UPDATE () function is executed, and the system will generate a SQL statement based on both buffers. ! Tb 01175004.gif

In Primary Buffer, the state of NOTMODIFIED and New! Will be ignored without generating SQL statements. The state of the DATAMODIFIED will generate an UPDATE statement, and the state of the NEWMODIFIED will generate an Insert statement, and the row in the DELETE buffer will produce a DELETE statement.

The use of four buffers in programming

Some DataWindow controls have functions that specify the DataWindow buffer. If default, the Primary buffer is indicated. The following is a function that can specify buffers:

· GetItemStatus ()

· GetNextModified ()

· GetUpdatestatus ()

· SetItemStatus ()

There are also GetItem ... series functions to query the value in DataWindow. These functions are:

· GetItemDate ()

GetItemDataTime ()

GetItemDecimal ()

· GetItemnumber ()

· GetItemString ()

· GetItemTime ()

转载请注明原文地址:https://www.9cbs.com/read-31062.html

New Post(0)