OD Reset 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 Reset context (context_ID) Integer

ParameterTypeDescription
context_IDLongintContext ID
Function resultIntegerError code
1 = the operation is successful
-1 = an error occurs

Description

OD Reset context allows you to re-execute a context's query and therefore asks 4D for Oracle to take into account the eventual addition and deletion of records taken place on the Oracle server. This function has the same effect as deactivating a context and reactivating it while preserving the open cursors and the allocated buffers, and with better results.

context_ID must be a context ID that has been previously created and is active.

OD Reset context is the equivalent of OD DEACTIVATE CONTEXT followed by OD Activate context. OD Reset context is, however, more efficient because the cursors and the retrieval buffers are preserved and the query is not reconstructed—it is simply re-executed.

If the context has been activated with the keys being preloaded, OD Reset context reloads them.

Notes:

After executing OD Reset context, the context is in the same state as after calling OD Activate context. In particular, the current row is no longer defined.

Because the reinitialization of a context implies the re-execution of the associated query, the context can consist of more or less records after its reinitialization.

After reinitializing an unsorted context, the records in the context can appear in a different order depending on the activity on the Oracle server.

When a record is created on the Oracle server by using OD Insert in context, it is not considered as being part of the context. In particular, calling OD Find in context will not find it.

Example

The following example uses OD Reset context to fix this problem. A context allows you to view the names of the employees who are in department 10 by using a dialog that offers the OD Next in context and OD Previous in context functions. The context is created and activated before the dialog box appears:

   ID_Context:=OD Create context ("scott.emp")
   OD ADD TO CONTEXT (ID_Context;"empno";->vEmpno;kKey)
   OD ADD TO CONTEXT (ID_Context;"ename";->vEname)
   OD ADD TO CONTEXT (ID_Context;"deptno";->vDept)
   OD SET CLAUSE IN CONTEXT (ID_Context;2;"deptno=10")

A button in the dialog box allows you to create a new employee record and to see it immediately in the context if the new employee belongs to department 10.

Here is the button's script:

   If (OD Insert in context (ID_Context)=1)
         `If the context was added, reinitialize the context so that it takes into
         `account this new record if it belongs to department 10
      $rc:=OD Reset context (ID_Context)
   End if

The same is true when you want to delete a record by using the OD Delete in context function.

Suppose that people work simultaneously on the same Oracle database and they move employees to another department. A new button allows the user to rebuild the context to take into account the modifications in the database.

The object method of this button is as follows:

   $rc:=OD Reset context (ID_Context)

See also

OD DEACTIVATE CONTEXT.


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