T.derive()

Read(141) Label: key value, field-adding,

Description:

Add a composite table’s fields to a table sequence or a cursor according to the latter’s key values.

Syntax:

T.derive(A/cs,x:C,…;wi,...)

Note:

The function adds one or more fields of composite table T to table sequence A or cursor/multicursor cs according to key values of the latter. It returns a table sequence when adding fields to a table sequence; and returns a cursor when adding fields to an ordinary cursor or a multicursor.

Parameters:

T

A composite table

A/cs

A table sequence/cursor/multicursor

x

Field value

C

Column alias;can be absent

wi

Filtering condition; separate multiple conditions, which should be met at the same time, by comma(s).

Return value:

A table sequence/cursor

Example:

 

A

 

1

=file("D:\\emp10.ctx")

 

2

=A1.create()

Open a composite table

3

=demo.query("select  EID from EMPLOYEE").keys(EID)

 

4

=A2.derive

(A3,NAME,GENDER)

Add fields of the composite table to A3’s table sequence by the latter’s key values

5

=demo.query("select  EID from EMPLOYEE").cursor()

 

6

=A2.derive(A5,NAME:NAME,GENDER:GENDER).fetch()

Add fields of the composite table to A5’s cursor by the latter’s key values

7

=file("D:/employees.ctx").create()

Open a composite table

8

=demo.query("select EID,DEPT from employee").keys(EID)

Return a table sequence with EID as the key

9

=A7.derive(A8,NAME:name,GENDER;GENDER=="M")

Add certain fields of A7’s composite table to A8’s table sequecne according to key values; filtering condition over A7 is GENDER=="M"