T.append(cs)

Read(292) Label: cursor, pseudo table,

Description:

Append-write records of a cursor to a pseudo table.

Syntax:

T.append(cs)

Note:

The function append-writes records of cursor cs to pseudo table T.

Parameter:

T

A pseudo table

cs

A cursor

Option:

@i

Append-write immediately at exit of the program or at retrieval while, by default, perform the operation when the number of records reaches to a specified number

@x

Calculate the zone table expression is at each append when append-writing data in a unicursor to a pseudo table whose source composite table is a multizone one because the cursor could correspond to multiple zones

@y

Write the appended records to the memory instead of keeping it in the external memory

Return value:

Pseudo table

Example:

Append-write to a pseudo table:

 

A

 

1

=create(file).record(["D:/file/Employee2.ctx"])

 

2

=pseudo(A1)

Generate a pseudo table object.

3

=create(Dept,AvgSalary).record(["CSD",6400.53])

 

Create a table sequence:

4

=A2.append@i(A3.cursor())

Append A3’s cursor record to the pseudo table.

Append-write a unicursor to a pseudo table:

 

A

 

1

=file("append/apps.ctx":[1,2]).create@yi(#eid, deptid;(deptid%2)+1)

 

2

=to(1,10000).new(~:eid,rand(5)+1:deptid)

Create a table sequence:

3

=pseudo(create(file,zone).record(["append/apps.ctx",[1,2]]))

Generate a pseudo table object.

4

=A3.append@ix(A2.cursor())

With @x option, append-write A2’s unicursor to two zones of A3’s pseudo table by calculating the zone table expression at each append.

Use @y option to write the appended records to the memory:

 

A

 

1

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

Return the pseudo table definition record.

2

=pseudo(A1)

Generate a pseudo table definition object.

3

=A2.import()

Read data from the pseudo table.

4

=create(EID,NAME).record([0,"AAAA"])

Return a table sequence:

5

=A2.append@y(A4.cursor())

Append table sequence A4’s records to pseudo table A2; @y option enables converting A4’s data to an in-memory zone table and writing it to the memory.

6

=A2.import()

Import data from the pseudo table, where there are records appended in A5.

7

>A2.close()

Close the pseudo table.

8

=pseudo(A1).import()

Import data from pseudo table A1; as A5 uses @y option and the appended data isn’t written to the external memory, the imported pseudo table data here does not contain A4’s data; the result is the same as A3’s: