Products Downloads


French version


 

 

ADELIA

      

      

      

      

(I/B)

 

 

 

 

 

Warning: In the case of ADELIA programs, this instruction is only compatible with the RPG generator.

 

Section for use

DECLARATION

 

Syntax

DECL CURSOR CursorName SeriesEntities Distinct SelectedColumns AdeliaCondition SortOption LinesOptimisation MaxLines

DECL CURSOR CursorName EntityName SelectedColumns AdeliaCondition SortOption Upd

 

SeriesEntities

SeriesEntities, Entity | Entity

Entity

EntityName CorrelationName | EntityName

Distinct

*DISTINCT | None

SelectedColumns

*COL(SeriesEntityFields | None

Upd

*UPD(SeriesEntityFields) | *UPD

SeriesEntityFields

SeriesEntityFields, EntityVarId | EntityVarId

LinesOptimisation

*OPT(n) | None

MaxLines

*LINES(x) | None

 

Description

This instruction defines a cursor CursorName for the entity or entities SeriesEntities.
It obeys the (optional) condition AdeliaCondition and the sequence for certain fields, being defined by the *SORT parameter, the fields concerned by SeriesSortFields and for each field, the sorting order Order. The order can be either *ASC for ascending or *DESC for descending. Where the Order is not specified, the default setting will be *ASC.

Click here for the explanation of the SortOption element.

 

By default, the instruction returns the values of all the entities' columns. However, it is possible to retrieve only the values which are specified in SelectedColumns.

 

If *DISTINCT is specified, only distinct lines are retrieved (as opposed to all columns or columns selected in SelectedColumns).

 

It is possible to ask the SQL optimizer to optimise the execution of the request in order to retrieve the first x lines of the cursor more quickly (*OPT parameter). By default, when the condition is not *COND(:VarId) type, a subfile in dynamic pagination works with an optimisation clause corresponding to the number of lines of subfile per page. To prevent Adelia from generating the optimisation clause, enter the *OPT(0) parameter.

 

Furthermore, it is possible to set the request optimizer to only retrieve the first x lines of the cursor (*LINES parameter).

 

The *UPD parameter enables the UPD_SQL_C and DELETE_SQL_C instructions to be used with this cursor. It can only be used if the cursor concerns a single entity.

 

If the cursor is used by the UPD_SQL_C instruction, you must specify the fields in the entity SeriesEntityFields that are to be updated.

When used alone, *UPD instructs the system to update all the fields (except the possible auto increment-type field).

 

Note: Versions prior to V6R1 of OS/400 do not accept sort fields that are also fields to be updated.

 

Example

* Declaration of a cursor reading CUSTOMERS and COMPANY, sorted by customer's name.

CURSOR CompCustCur CUSTOMER, COMPANY  *COND(CUS_COMP_COD = CPY_COMP_COD) *SORT(CUS_CUST_NAM)

 

* Declaration of a cursor reading ORDERS (order number, customer's name and amount), sorted by amount.

DECL CURSOR Cursor1 ORDERS *COL(OORDER_NUM, OCUST_NAME, OAMOUNT) *COND(OAMOUNT > 1,000) *SORT(OAMOUNT)

 

* Declaration of a cursor reading ORDERS, with possible update for Item_Price field.

DECL CURSOR Cursor2 ORDERS *COND(OAMOUNT > 1,000) *UPD(OITEM_PRICE)

 

* Declaration a cursor which allows to update all fields from AGREEMENTS entity.

DECL CURSOR CURS_AGREEMENTS AGREEMENTS *COND(AINSUR_ID = :ZINSU_ID) *UPD

 

See also the list of 4GL instructions by topic

↑ Top of page

  • Aucune étiquette