6.64 LceSetSelectOptions

Specifies the options to be used for the next SELECT or FETCH function. This function sets the characteristic of the search when an LceRequestSelect or LceSelect function is used. It is also used for record locking when an LceFetch function is used.

BOOL

LceSetSelectOptions

(int

iSession,

 

 

 char far *

strOptions ) 

  

Parameters

iSession

The session identifier as returned by LceGetSessionId.

strOptions

A comma-separated list of SELECT or FETCH options. The options used will revert to their default values after the next LceRequestSelect or LceFetch function.  Refer to the Notes for details.

  

strOptions

Valid SELECT options:

*BACKWARDS

Records are retrieved in reverse order.

*STARTKEY

This key is used as the starting position for the select.

*MAXRECnn

Select a maximum of nn records.

*BLOCKBYKEY[nnnn]

Block by key. Only valid on IBM i hosts.

*BLOCKBYRRN[nnnn]

Block by relative record number. Only valid on IBM i hosts.

*RECEIVEIMMED

Receive immediately.

  

Valid FETCH option:

*LOCK

Locks the record to prevent access by another application.

  

If no options are specified, or if one is missed, the default for that option is used. After the next Select request, these defaults are re-instated.

The default options for SELECT are:

 

Forward record retrieval.

 

No *STARTKEY option.

 

No record selection limit.

 

No record locking.

 

No blocked I/O performed.

 

The records will not be returned until they've all been read at the host.

  

The default option for FETCH:

 

No record locking.

  

Return Values

TRUE is returned if valid options are set.

FALSE is returned if an error occurs.

Notes

Portability Considerations

The options *BLOCKBYKEY and *BLOCKBYRRN and *LOCK are only valid on IBM i hosts. They are ignored on other platforms.

For RDMLX files, *BLOCKBYKEY and *BLOCKBYRRN are always ignored.

For RDML files, *BLOCKBYKEY and *BLOCKBYRRN are valid for IBM i hosts, but ignored on other platforms.

The option *LOCK is only valid on IBM i hosts. It is ignored on other platforms. For RDMLX files, if the OAM cannot support locking because it is using SQL, an error will be returned from the LceFetch call.

  

*BACKWARDS

Records are retrieved in reverse order. This option indicates that rows are to be processed in reverse order to that which would normally be used. Backwards processing by sequential, full or partial key is supported.

This option must not be used with either of the *BLOCKBY options.

*STARTKEY

The key is used as the starting position for the first read operation. The first record read will be the first one which has a key equal to or greater than the key values specified. All subsequent records are then processed with no regard to the keys.

*MAXRECnn

This option is used to indicate the maximum number of records which are to be returned. It can be used with all other select options.

The nn parameter must be specified and it must be greater than zero, otherwise no records will be returned.

*BLOCKBYKEY[nnnn]

Block by key.

This is a select option that will improve application performance, depending on whether the data is in the same physical order as the primary key of the file. *BLOCKBYKEY is generally less efficient than *BLOCKBYRRN unless the IBM i physical file has been recently reorganized. (Reorganization ensures that the data is in the same order as the file's primary key.)

This option cannot be specified with the *BLOCKBYRRN option. i.e. You cannot specify both options.

Important Note: This option is only valid on IBM i hosts. It is ignored on other platforms.

Note the following about using this option:

*BLOCKBYRRN[nnnn]

Block by relative record number.

*BLOCKBYRRN is generally the most efficient type of IBM i sequential database file access. Used correctly and with an appropriate blocking factor, it can improve sequential access time by a factor of 10 or more. This improvement may not be significant, however, if communications between the IBM i and your PC are slow.

This option cannot be used with the *BLOCKBYKEY option. i.e. You cannot specify both options.

Important Note: This option is only valid on IBM i hosts. It is are ignored on other platforms.

Note the following about using this option:

*RECEIVEIMMED

Receive immediately, to indicate that the next Select operation is to be performed in "immediate" mode. This option may substantially improve the time taken to select rows, particularly where a large number are involved.

Note the following about using this option:

The LceSetSelectOptions function is used with a number of other select processing functions. The general pattern of these functions is as follows if the *RECEIVEIMMED option is not used:

If the *RECEIVEIMMED option is used, then the functions will be as follows:

Related Functions

6.15 LceFetch

6.50 LceRequestSelect

6.49 LceReceiveSelect

6.51 LceRequestSelectWhere

6.48 LceReceiveNextX

6.37 LceGetRecordCount

6.38 LceGetSelect

6.53 LceSelect

6.11 LceDeleteSelect