You can access data values in a DataWindow by using methods or DataWindow data expressions. Both methods allow you to access data in any buffer and to get original or current values.
The method you use depends on how much data you are accessing and whether you know the names of the DataWindow columns when the script is compiled.
For guidelines on deciding which method to use, see the DataWindow Reference.
There are several methods for manipulating data in a DataWindow control.
These methods obtain the data in a specified row and column in a specified buffer (Web DataWindow methods have separate methods for overloaded versions):
PowerBuilder GetItemDate, GetItemDateTime, GetItemDecimal, GetItemNumber, GetItemString, GetItemTime
Web DataWindow server component GetItemDate, GetItemDateByColNum, GetItemDateByColNumEx, GetItemDateEx, GetItemDateTime, GetItemDateTimeByColNum, GetItemDateTimeByColNumEx, GetItemDateTimeEx, GetItemNumber, GetItemNumberByColNum, GetItemNumberByColNumEx, GetItemNumberEx, GetItemStatus, GetItemStatusByColNum, GetItemString, GetItemStringByColNum, GetItemStringByColNumEx, GetItemStringEx, GetItemTime, GetItemTimeByColNum, GetItemTimeByColNumEx, GetItemTimeEx
This method sets the value of a specified row and column:
Web DataWindow server component SetItemDate, SetItemDateByColNum, SetItemDateTime, SetItemDateTimeByColNum, SetItemNumber, SetItemNumberByColNum, SetItemStatus, SetItemStatusByColNum, SetItemString, SetItemStringByColNum, SetItemTime, SetItemTimeByColNum
For example, the following statement, using PowerBuilder syntax, assigns the value from the empname column of the first row to the variable ls_Name in the Primary buffer:
ls_Name = dw_1.GetItemString (1, "empname")
This PowerBuilder statement sets the value of the empname column in the first row to the string Waters:
dw_1.SetItem(1, "empname", "Waters")
Uses You call the GetItem methods to obtain the data that has been accepted into a specific row and column. You can also use them to check the data in a specific buffer before you update the database. You must use the method appropriate for the column’s datatype.
For more information about the methods listed above, see the DataWindow Reference.
DataWindow data expressions refer to single items, columns, blocks of data, selected data, or the whole DataWindow.
The way you construct data expressions depends on the environment:
Expressions in PowerBuilder The Object property of the DataWindow control lets you specify expressions that refer directly to the data of the DataWindow object in the control. This direct data manipulation allows you to access small and large amounts of data in a single statement, without calling methods:
dw_1.Object.jobtitle[3] = "Programmer"
The next statement sets the value of the first column in the first row in the DataWindow to Smith:
dw_1.Object.Data[1,1] = "Smith"
For complete instructions on how to construct DataWindow data expressions, see the DataWindow Reference.