Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Specifying field lists in the 4GL

> You can specify a field list in two different 4GL contexts:

> - Following each buffer name specified in a `DEFINE` `QUERY` statement.

> - Following the buffer name specified for fetching in each Record phrase of a `FOR`, `DO` `PRESELECT`, or `REPEAT` `PRESELECT` statement.

> This is the syntax for specifying a field list in all cases:

> Syntax
>     record-bufname
>       [   FIELDS [ ( [ field ... ] ) ]
>       | EXCEPT [ ( [ field ... ] ) ]
>     ]

> The`record`–`bufname` reference specifies the table buffer you are using for the fetch, and a `field` reference specifies a field in the table. If `field` is an array reference, the whole array is fetched. The `FIELDS` form lists the fields included in the fetch, and the `EXCEPT` form lists the fields excluded from the fetch. `FIELDS` without `field` references fetches enough information to return the `ROWID` of a record, and `EXCEPT` without `field` references or `record`–`bufname` alone fetches a complete record.

> ##### Queries versus record selection blocks

> For a query, you must specify the field lists in the `DEFINE` `QUERY` statement, not the Record phrase of the `OPEN` `QUERY` statement. Thus, the following two procedures, `i-fldls1.p` and `i-fldls2.p`, are functionally equivalent:

> i-fldls1.p
>     DEFINE QUERY custq FOR customer FIELDS (name cust-num balance).
>     OPEN QUERY custq PRESELECT EACH customer.
>     REPEAT:
>         GET NEXT custq.
>         IF AVAILABLE(customer)
>             THEN DISPLAY name cust-num balance.
>             ELSE LEAVE.
>     END.

> i-rldls2.p
>     REPEAT PRESELECT EACH customer FIELDS (name cust-num balance):
>         FIND NEXT customer.
>         DISPLAY name cust-num balance.
>     END.

> ##### Shared queries

> If you specify field lists in a `NEW` `SHARED` query, the matching `SHARED` query definitions in external procedures only have to include the `FIELDS` or `EXCEPT` keyword as a minimum field list reference. The complete field list is optional in the `SHARED` query definitions, but required in the `NEW` `SHARED` query definition.

> However, Progress raises the `ERROR` condition when you run a procedure with a `SHARED` query if you:

> - Specify a field list in the `SHARED` query to match a `NEW` `SHARED` query that has no field list.

> - Do not specify a field list reference in the `SHARED` query to match a `NEW` `SHARED` query that has a field list.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095