Example: custlist.4gl (Function custlist_query)
The custlist_query function implements the CONSTRUCT instruction to
get an SQL condition that will be used in the SELECT statement to filter customer
table rows.
The
custlist_query function in
custlist.4gl: 1 PRIVATE FUNCTION custlist_query() RETURNS STRING
2 DEFINE sql_cond STRING
3
4 CLEAR FORM
5
6 LET int_flag = FALSE
7 CONSTRUCT BY NAME sql_cond ON cust_num, cust_name
8
9 IF int_flag THEN
10 RETURN NULL
11 ELSE
12 RETURN sql_cond
13 END IFNote:
- Line
1defines the function with not parameters, and a single return value of typeSTRING. - Line
4clears all form fields with theCLEAR FORMinstruction. - Line
6resets theint_flagregister toFALSE. - Line
7declares theCONSTRUCTinstruction. For more details, go to Tutorial Chapter 4: Query by Example. - Lines
9thru13: Depending on the int_flag, we return the SQL condition or NULL, if the user has selected the Cancel button.