T.derive()

Description:

Define the computation of adding fields to a pseudo table and return a new pseudo table.

Syntax:

T.derive(xi :Fi,…)

Note:

The function defines a computation on pseudo table T, which computes expression xi on each of T’s records and makes the results field values of the new fields Fi,…, and returns a new pseudo table consisting of the original fields of T and fields Fi,….

Parameter:

T

A pseudo table

Fi

Field names, which should not be same as names of the existing fields in T

xi

Expression, whose results are used as field values

Option:

@i

Do not generate a corresponding record for a row when parameter xi is present and its computing result is null

Return value:

Pseudo table

Example:

 

A

 

1

=create(file).record(["emp.ctx"])

Below is content of composite table emp.ctx:

2

=pseudo(A1)

Generate a pseudo table object.

3

=A2.derive(interval@y(BIRTHDAY,HIREDATE):EntryAge, age(HIREDATE):WorkAge)

Define a computation on A2’s pseudo table, where EntryAge field and WorkAge field will be added, and return a new pseudo table.

4

=A3.import()

Import data from A3’s pseudo table while the computation defined on A2’s pseudo table in A3 is executed, and return the following content: