OD ADD TO 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 ADD TO CONTEXT (context_ID; sqlExp; pointerTo4DObj{; options})

ParameterTypeDescription
context_IDLongintConnection identifier
sqlExpTextOracle column or expression
pointerTo4DObjPointerPointer to a 4th Dimension variable, array, or field
optionsLongintOptions for the bind

Description

The OD ADD TO CONTEXT command binds a 4th Dimension object with an Oracle column or expression. The bind is added to the context definition initiated by OD Create context.

context_ID must be a previously created and inactive context identifier.

sqlExp specifies either the name of an Oracle column (in the table.column or column format) or a SQL expression (such as "sal*1.15"). Unless you declared a default table name for a column you want to select, you must specify the table in which the column is located using the table.column format. You can specify a default table name using either OD Create context dialog or OD Create context.

pointerTo4DObject is a pointer to a 4th Dimension field, variable, or array.

options is an integer representing the sum of the options you wish to set:

OptionDescription
kForUpdate=1Applies only to Oracle columns. Columns with this option can be updated by
OD Insert in context or OD Update in context. SQL expressions cannot be
updated.
kSortAsc=2Performs an ascending sort on the Oracle values.
kSortDesc=4Performs a descending sort on the Oracle values.
kKey=8Applies only to Oracle columns. Specifies that the column is part of the
primary key that uniquely identifies the rows in the context. Specifying a
primary key allows you to access rows in an order other than from first to last
using OD Previous in context or OD Goto in context when the rowid special
column is not available.

When you set any of these options, you help define the clauses for the SELECT statement that will be generated when you activate the context.

The clauses are defined as follows:

SELECT: The SELECT clause includes the columns or expressions to be used in the selection. A column or expression can be specified in the SQLExp parameter.Values from multiple SQLExp parameters are separated by commas.

FROM: The FROM clause includes the tables from which rows will be selected. You must specify at least one table. If you specify a table in the SQLExp parameter using the table.column format, the table you specify will be listed in the FROM clause. If you do not specify a table in the SQLExp parameter, 4D Oracle uses the default table you specified with the OD Create context or OD Create context dialog functions.

FOR UPDATE OF: The FOR UPDATE OF clause includes the names of all columns that have the kForUpdate option, as long as the kWithLock option has been set for this context with OD SET OPTIONS. If no columns have the kForUpdate option, or if the kReadOnly option has been set with OD SET OPTIONS, the FOR UPDATE OF clause is omitted.

ORDER BY: The ORDER BY clause includes the numbers of the binds, in the order of their creation, that have the kSortAsc or kSortDesc option. The number of the bind is followed by "ASC" or "DESC" to indicate if the sort should be ascending or descending.

Other clauses may appear according to the context defined in the Edit a Context dialog box. Some clauses may be modified by calling OD SET CLAUSE IN CONTEXT before activating the context.

Example

The following method initiates a context definition and then defines the binds within the context:

   kForUpdate:=1    `Define constants for clauses
   kSortAsc:=2
   kSortDesc:=4
   Context_ID := OD Create context ("EMP")    `Initiate a context definition
   OD ADD TO CONTEXT (Context_ID; "empno"; ->[Employees]No)
   OD ADD TO CONTEXT (Context_ID; "ename"; ->[Employees]Name;kForUpdate+kSortAsc)
   OD ADD TO CONTEXT (Context_ID; "sal/1000"; ->vSalaryKF; kSortDesc)

When the context is activated using OD Activate context, the following SELECT statement is sent to the Oracle server:

   SELECT empno, ename, sal/100 FROM emp ORDER BY 2 ASC, 3 DESC

Since only the second OD ADD TO CONTEXT command has the kForUpdate option, only the ename column can be updated by a call to OD Update in context or OD Insert in context.

See Also

OD Activate context, OD Create context.


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