cs .derive()

Read(145) Label: cursor, add field, field name,

Description:

Add one or more fields to a cursor.

Syntax:

cs.derive(xi :Fi,…)

Note:  

The function adds Fi,… fields to cursor cs, making a new cursor having “orginal fields of channel ch plus Fi,…”, and then traverses each of the records of cs to compute expression xi. It supports multicursors.

Parameters:  

cs

Cursor

Fi

Field name. In this case, Fi cannot be of the same name as the existing fields in cs

xi

Expression, whose computed results are the field values

Options:

@i

Won’t generate a record if the result of expression xi is null (this won’t affect a record with null value in the original table sequence)

Return value:

The original cursor cs

Example:

 

A

 

1

=demo.cursor("select NAME,BIRTHDAY,HIREDATE from Employee")

 

2

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

Add fields EntryAge and WorkAge to the original cursor.

3

=A2.fetch()

4

=file("D:\\txt_files\\data1.txt").cursor@t()

Below is the file data1.txt:

5

=A4.derive@i(SCORE:score_not_null)

If the SCORE value is null, the corresponding record won’t be generated

 

6

=A5.fetch()

Related functions:

cs.new()