cs.news()

Read(242) Label: field value, update, cursor,

Description:

Compute new cursor field values to update them into the original cursor.

Syntax:

cs.news(X;xi:Fi,…)

Note:

The function computes field values based on cursor cs, updates the newly-computed fields into the original cursor where xi is field value of each record and Fi is the new field name, which will be automatically identified if Fi is omitted.

Parameters:

cs

Cursor

X

Record sequence

xi

An expression, whose values are uses as the new field values. It is treated as null if omitted; in that case, : Fi can’t be omitted. The sign # is used to represent a field with a sequence number

Fi

Filed name of the new cs; use the identifiers parsed from expression xi if it is omitted

Options:

@1  Left join, which creates an empty record when record sequence X is empty

Return value:

The original cursor with the new field values

Example:

 

A

 

1

=demo.cursor("select * from EMPLOYEE")

 

2

=demo.query("select * from EMPLOYEE")

 

3

=A2.group(GENDER;~:group)

Perform group by GENDER

4

=A1.groupx(GENDER;avg(SALARY):avg)

Perform group by GENDER

5

=A4.join(GENDER,A3:GENDER,group)

 

6

=A5.news(group;EID,NAME,GENDER,#3:surname, age(~.BIRTHDAY):age,SALARY+50: salary,avg:AvgSalary)

A4 is composed of data groups; based on each group field values are computed and a cursor is generated; and then cursors are concatenated into a new one.

7

=A6.fetch()

 

8

=MySQL1.query("select * from EMPLOYEE")

 

9

=A8.group(GENDER;~:group)

Group GENDER field

10

=A4.join(GENDER,A9:GENDER,group)

11

=A10.news@1(group;EID,NAME,GENDER,age(~.BIRTHDAY):age,salary,avg:AvgSalary)

Compute each GENDER value for each group, generate an empty table for the group where GENDER is M and then concatenate result records into a new table sequence

12

=A11.fetch()

Related functions:

A.news(X;xi:Fi,…)