T.derive()

Read(305) 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 the latter’s key, which should be in the same order as the existing fields of T. . It returns a table sequence when adding fields to a table sequence; and returns a cursor, which will be sorted by T’s dimension or key. 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).

Options:

@z

Match existing fields in A/cs with T’s dimension or key

 

Return value:

A table sequence/cursor

Example:

 

A

 

1

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

 

2

=A1.open()

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").open()

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"

10

=demo.query("SELECT EMPLOYEEID,EVALUATION,BONUS FROM PERFORMANCE")

Return a table sequence

11

=A2.derive@z(A10,EID,NAME)

Use @z option to match A10’s existing fields with the key of A2’s composite table