cursor()

Read(1264) Label: genrate a cursor, path,

Description:

 Call a cellset file and return the result set returned from the execution of the file as a cursor.

Syntax:

cursor(dfx,…)

Note:

The function calls a cellset file and returns the result set returned from the execution of the file as a cursor. When there are multiple return statements in the dfx file, first merge the result sets returned by the return statements, and then return the merge result as a cursor. These result sets of return must be of the same structure, or error will be reported. Use either an absolute path or a relative path to search for the dfx file. With the relative path, the search order is Class path –> Search path –> Main directory. The cursor the function returns is irreversible.

Parameter:

dfx

Cellset file name

dfx’s parameter

Option:

@c

The dfx can be represented by a cell that corresponds to a subroutine defined by func() function

Return value:

Cursor

Example:

Here’s test.dfx cellset file under the main directory in which arg1 is the cellset parameter:

 

A

B

 

1

for arg1

 

 

2

 

=connect("demo").query("select * from GYMNASTICSWOMEN where ID=?",A1)

 

3

 

=B2.derive(avg(VAULT,UNEVENBARS,BALANCEBEAM,FLOOR):Average)

 

4

 

return B3

Perform a loop computation and return the result sets.

 

 

A

 

1

=[5,10,20,25]

 

 

2

=cursor("test.dfx",A1)

Cll test.dfx, pass A1’s sequence as the value of parameter arg1, and return result as a cursor.

3

=A2.fetch()

Fetch records from the cursor; the result is the union of returned result sets by the loop computation of test.dfx.

4

=call("test.dfx",A1)

Use call function to call test.dfx but only the result set of the first loop is returned. 

 

 

A

B

 

1

func

 

 

2

 

return A1.sum()

 

3

=cursor@c(A1,[2,5,7])

 

Call the code block whose master cell is A1.

4

=A3.fetch()

 

14.