OD Next in context

4D - Documentation   Français   English   German   English   4D for Oracle, Command Theme List   4D for Oracle, Command Alphabetical List   Back   Previous   Next

version 1.5


OD Next in context (context_ID{; index}) Integer

ParameterTypeDescription
context_IDLongintContext identifier
indexIntegerIndex array
Function resultIntegerError code
1 = the operation is successful
-1 = an error occured

Description

The OD Next in context function loads the result row following the current row. If the current row is undefined, as is the case after OD Activate context, OD Next in context loads the first result row.

context_ID must be a previously created and active context identifier.

OD Next in context updates the 4th Dimension objects with the row. For binds involving fields, the current record is updated but not saved. If a current record does not exist, OD Next in context ignores the bind.

index applies only to binds involving arrays. If index is not specified, OD Next in context updates the lines of the arrays that correspond to the number of the new current row. If index is specified, OD Next in context updates the lines of the arrays with the index index. If index is beyond the limits of an array, OD Next in context adds a new line to the array.

OD Next in context returns -1 in case of error. Otherwise, it returns 1.

Example

The following method defines a context between the EMP table and the [Employees] table to store employees who are part of a pre-defined array:

   Context_ID := OD Create context ("EMP")    `Create context, define binds
   OD ADD TO CONTEXT (Context_ID; "empno";->[Employees]No; 0)
   OD ADD TO CONTEXT (Context_ID; "ename"; ->[Employees]Name; 0)
   OD ADD TO CONTEXT (Context_ID; "sal"; ->[Employees]Salary; 0)
   err:=OD Activate context (Login_ID; Context_ID)   `Activate context
   If (err=1)
      CREATE RECORD ([Employees])   `Create record to load results
      err:=OD Next in context (Context_ID)   `Load first result row
      While (err=1)
         If (Find in array (aArray;[Employees]Name)#-1)    `If employee is in array
            SAVE RECORD ([Employees])   `Save record
            CREATE RECORD ([Employees])   `Create new record
         End if
         err:=OD Next in context (Context_ID)   `Move to next row in context
      End while
      OD DEACTIVATE CONTEXT (Context_ID)   `Deactivate context
   End if 

See Also

OD Activate context, OD Previous in context.


4D - Documentation   Français   English   German   English   4D for Oracle, Command Theme List   4D for Oracle, Command Alphabetical List   Back   Previous   Next