Description:
Attach the action of computing new field values to a cursor and return the original cursor.
Syntax:
cs.new(xi:Fi,…)
Note:
The function attaches a computation to cursor cs, which computes expression xi against each record in cursor cs to generate a new table sequence having same number of records as that in cs, consisting of the field Fi whose values are results of expression xi,, and returns the table sequence to the original cursor.
This is a delayed function.
Parameter:
cs |
A cursor |
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 |
Field name of cs; use the identifiers parsed from expression xi if it is omitted |
Option:
@i |
Won’t generate a record if the result of expression xi is null |
Return value:
Cursor
Example:
|
A |
|
1 |
=connect("demo").cursor("select top 5 * from SCORES where SCORE<60") |
|
2 |
=A1.new(#2:ID,CLASS,SCORE+5:newScores) |
Attach the action of computing an expression to cursor A1; #2:ID means renaming the 2nd field in cursor A1 ID; the attached computation will compute expression SCORE+5 on SCORE field and rename the field newScores and form a table sequence consisting of ID, CLASS and newScores to return to cursor A1. |
3 |
=A1.fetch() |
Fetch data from cursor A1 where A2’s computation is already executed (it would be better to fetch data in batches when a huge amount of data is involved):
|
When @i option works:
|
A |
|
1 |
=file("D:\\txt_files\\data1.txt").cursor@t() |
Below is the file data1.txt: |
2 |
=A1.new@i(CLASS,STUDENTID,SUBJECT,SCORE:score) |
With @i option, if the SCORE value is null, the corresponding record won’t be generated. |
3 |
=A1.fetch() |
Fetch data from cursor A1 where A2’s computation is already executed:
|