GetItemNumber

Description

Gets numeric data from the specified buffer of a DataWindow control or DataStore object. You can obtain the data that was originally retrieved and stored in the database from the original buffer, as well as the current value in the primary, delete, or filter buffers.

NoteSeparate method names for the Web DataWindow server component Separate method names, GetItemNumberEx, GetItemNumberByColNumEx, and GetItemNumberByColNum, are provided as alternative syntaxes for the Web DataWindow server component, which cannot use overloaded methods.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object

Web

Server component

Web ActiveX

DataWindow control, DataWindowChild object

Syntax

PowerBuilder

numeric dwcontrol.GetItemNumber ( long row, string column
	 {, DWBuffer dwbuffer, boolean originalvalue } )
numeric dwcontrol.GetItemNumber ( long row, integer column 
	{, DWBuffer dwbuffer, boolean originalvalue } )

Web DataWindow server component

double dwcontrol.GetItemNumber ( long row, string column )
double dwcontrol.GetItemNumberByColNum ( long row, short column )
double dwcontrol.GetItemNumberEx ( long row, string column,
	stringdwbuffer, boolean originalvalue )
double dwcontrol.GetItemNumberByColNumEx ( long row, 
	short column, string dwbuffer, boolean originalvalue )

Web ActiveX

number dwcontrol.GetItemNumber ( number row, string column,
	number dwbuffer, boolean originalvalue )
number dwcontrol.GetItemNumber (number row, number column,
	number dwbuffer, boolean originalvalue )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow.

row

A value identifying the row location of the numeric data.

column

The column location of the numeric data. The datatype of the column must be one of a numeric datatype. Column can be a column number or a column name. The column number is the number of the column as it is listed in the Column Specification view of the DataWindow painter—not necessarily the number of the column in the Design view.

To get the contents of a computed field, specify the name of the computed field for column. Computed fields do not have numbers.

dwbuffer (optional)

A value identifying the DataWindow buffer from which you want to get the data. For a list of valid values, see DWBuffer.

originalvalue (optional)

A boolean indicating whether you want the original or current values for row and column:

  • True – Return the original values (the values initially retrieved from the database).

  • False – (Default) Return the current values.

If you specify dwbuffer, you must also specify originalvalue.

Returns

Returns the numeric value in the specified row and column (decimal, double, integer, long, or real). Returns null if the column value is null or if there is no DataWindow object assigned to the DataWindow control or DataStore. Triggers the SystemError event and returns –1 if any other error occurs (see “Handling errors”).

If any argument value is null, in PowerBuilder and JavaScript the method returns null.

Usage

Use GetItemNumber to get information from the DataWindow’s buffers. To find out what the user entered in the current column before that data is accepted, use GetText. In the ItemChanged or ItemError events, use the data argument.

To access a row in the original buffer, specify the buffer that the row currently occupies (primary, delete, or filter) and the number of the row in that buffer. When you specify true for originalvalue, the method gets the original data for that row from the original buffer.


Handling errors

The return value is a valid value from the database unless the SystemError event is triggered. When the value cannot be converted because the column’s datatype does not match the method’s datatype, an execution error occurs, which triggers the SystemError event. The default error processing halts the application. If you write a script for the SystemError event, it should also halt the application. Therefore, the error return value is seldom used.

Examples

Example 1

These statements set EmpNbr to the current numeric data in the primary buffer for row 4 of the column named emp_nbr in dw_employee:

integer EmpNbr

EmpNbr = dw_employee.GetItemNumber(4, "emp_nbr")

Example 2

These statements set EmpNbr to the current numeric data in the filter buffer for row 4 of the column named salary of dw_employee:

integer EmpNbr

EmpNbr = dw_employee.GetItemNumber(4, &

		"salary", Filter!, false)

Example 3

These statements set EmpNbr to the original numeric data in the primary buffer for row 4 of the column named salary of dw_Employee:

integer EmpNbr

EmpNbr = dw_Employee.GetItemNumber(4, &

		"salary", Primary!, true)

See also