FindRequired – PB Docs 150

FindRequired method (DataWindows)

Description

Reports the next row and column that is required and contains
a null value. The method arguments that specify where to start searching
also store the results of the search. You can speed up the search
by specifying that FindRequired check only inserted
and modified rows.

Controls

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataStore object

Web ActiveX

DataWindow control

Syntax

[PowerBuilder]

[Web ActiveX]

Argument

Description

dwcontrol

A reference to the DataWindow control
or DataStore in which you want to find required columns that have
null values.

dwbuffer

A value indicating the DataWindow buffer
you want to search for required columns. Valid buffers are:

  • Primary!

  • Filter!

row

A value identifying the first row to
be searched. Row also stores the number of the found row. FindRequired increments the
row number automatically after it validates each row’s columns.
When it finds a row with a required column that contains a null
value, the row number is stored in row. After FindRequired validates
the last column in the last row, it sets row to
0.

PowerBuilder

The row argument must be a variable so
it can return a value for the found row.

colnbr

A value identifying the first column
to be searched. Colnbr also stores the number
of the found column. After validating the last column, FindRequired sets colnbr to
1 and increments row. When it finds a required
column that contains a null value, the column number is stored in
colnbr.

PowerBuilder

The colnbr argument must be a variable
so it can return a value for the found column.

colname

A string in which you want to store the
name of the required column that contains a null value (the name
of colnbr).

PowerBuilder

The colname argument must be a variable
so it can hold a value for the name of the found column.

updateonly

A value indicating whether you want to
validate all rows and columns or only rows that have been inserted
or modified:

  • true – Validate
    only those rows that have changed. Setting updateonly to true enhances
    performance in large DataWindows.

  • false – Validate all
    rows and columns.

Return Values

Returns 1 if FindRequired successfully
checked the rows and –1 if an error occurs.

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

Usage

For FindRequired to report an empty required
column, the column’s value must actually be null, not an
empty string.

To make a column required, set the Required property to true
in a script or check the Required check box for the column in the
DataWindow painter.

New rows have null values in their columns, unless the columns
have default values. If updateonly is false, FindRequired reports
empty required columns in new rows. If updateonly is
true, FindRequired does not check new rows because
new, empty rows are not updated in the database.

When the user modifies a row and leaves a column empty, the
new value is an empty string, unless the column’s edit
style has the Empty String Is null check box checked. FindRequired does
not report empty required columns in modified rows unless this property
is set.

Examples

The following code makes a list of all the row numbers
and column names in dw_1 in which required columns are
missing values. The list is displayed in the MultiLineEdit mle_required:

This example is a function that ensures that no required
column in a DataWindow control is empty (contains null). It takes
one argument—the DataWindow control, which is declared
in the function declaration like this:

The function returns –2 if the user’s last
entry cannot be accepted or if FindRequired returns
an error. It returns –1 if an empty required column is found.
It returns 1 if all required columns have data:

See Also


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x