append()

Read(292) Label: append,

Here’s how to use append() function.

T.append( cs )

Description:

Append records in a cursor/distributed cursor to an entity table.

Syntax:

T.append(cs)

 

Note:

The function appends records in cursor/distributed cursor cs to entity table T. Append records to the last file if T is a file group; structures of cs and T should be the same if the former is a distributed cursor; the appending action can be performed only when the parent table isn’t empty and data is ordered by a key and maintains unique, because the attached table needs to be segmented according to the order of data in the base table. Append records to a cluster table with a segmentation function when cs isn’t a distributed cursor.

The data appended to an attached table must be ordered by a dimension. Data in an attached table should be aligned with the data in the base table through the primary key. The parent table can have records that don’t exist in a sub table, but the opposite situation is not allowed; otherwise the appending to an attached table will be disabled.

If a table has an attached table, appending data to the parent table requires that data be ordered and be unique; otherwise error will be reported. An empty cluster composite table can only receive data from a cluster cursor; but if it isn’t empty, it can receive data from an ordinary cursor.

Parameters:

T

An entity table

cs

A cursor/distributed cursor

Options:

  @m  A merge appending; doesn’t support an attached table

@i

Real-time appending whenever a retrieval happens and when the application exits; by default an appending is executed only when there is a specified number of new records

Return value:

An entity table

Example:

1

=create(k1,v1).record([1,10,2,20,3,30,4,40,10,100])

Create a table sequence

2

=create(k1,k2,v2).record([1,1,"a",3,1,"c"])

Create a table sequence

3

=create(k1,v3).record([1,"red",1,"blue",2,"red",2,

"yellow",2,"red",2,"red",4,"black",4,"red",4,"red",

4,"red",4,"red",4,"red",10,"red"])

Create a table sequence

4

=file("D:/ctb.ctx")

 

5

=A4.create(#k1,v1)

Create the composite table’s base table, where k1 is a dimension and v1 is the base table’s column

6

=A5.attach(table2,#k2,v2)

Add attached table table2 to A5’s base table; k1 and k2 are the attached table’s dimensions and v2 is its column

7

=A5.attach(table3,v3)

Add attached table table3 to A5’s base table; k1 is the attached table’s dimension and v3 is its column

8

=A5.append(A1.cursor())

Append cursor records to the base table

9

=A6.append(A2.cursor())

Append cursor records to attached table table2

10

=A7.append(A3.cursor())

Append cursor records to attached table table3

11

=A5.cursor().fetch()

Return data of the base table

12

=A6.cursor().fetch()

Return data of the attached table table2

13

=A7.cursor().fetch()

Return data of the attached table table3

14

=file@zw("emp1.ctx",["192.168.0.131:8281"])

 

15

=A14.create(#EID,NAME,GENDER;;"@!*123":"12")

Create an encrypted cluster composite table

16

=file@0("employee1.ctx",["192.168.0.131:8281"])

Generate a cluster duplicated file

17

=A16.create()

Create a duplicated cluster composite table

18

=A17.cursor(EID,NAME,GENDER;EID<6)

Return cluster composite table employee1 as a cursor

19

=A15.append(A18)

Append data of the cluster cursor into the newly-created encrypted composite table emp1

20

=A15.cursor(EID,NAME,GENDER;EID<4).fetch()

Below is the fetched data:

21

=demo.cursor("select EID,NAME,GENDER from employee where EID<10")

Return an ordinary cursor

22

=A15.append(A21)

As the cluster composite table already has data, it can receive data from an ordinary cursor

23

=A15.cursor(EID,NAME,GENDER;EID<4).fetch()

Below is the table after data appending:

24

=file(["D:\\emp12.ctx","D:\\emp11.ctx"])

 

25

=A24.create()

 

26

=demo.cursor("select EID,NAME,GENDER from employee where EID<30")

 

27

=A25.append(A16)

 

28

=A24.create().cursor().fetch()

29

=A25.append@m(A16)

Perform merge appending with @m option

30

=A19.create().cursor().fetch()

 

f.append()

Description:

Cocatenate two same-structure composite table.

Syntax:

f.append( f’,p)

 

Note:

The function appends an unencrypted composite table file f’ to another composite table file f. The two should have same structure, otherwise the appending will fail. Once the appending fails, use rollback() function to restore the previous state. Parameter p can be omitted if f is an unencrypted composite table file.

Parameters:

f’

A composite table file

p

The write password for composite table file f

Options:

@x

Delete f’after the appending

Return value:

A composite table file

Example:

 

A

 

1

=file("D:\\append1.ctx")

 

2

=A1.create(#EID,NAME,DEPT,SALARY)

Create the composite table’s base table

3

=demo.cursor("select EID,NAME,DEPT,SALARY from EMPLOYEE where EID<10 order by  EID")

 

4

=A2.append(A3)

Append cursor records to the entity table

5

=file("D:\\append2.ctx")

 

6

=A5.create(#EID,NAME,DEPT,SALARY)

Create the composite table’s base table

 

7

=demo.cursor("select EID,NAME,DEPT,SALARY from EMPLOYEE where  EID>10and  EID<20  order by  EID")

 

8

=A6.append(A7)

Append cursor records to the entity table

9

=A1.append(A5)

Append unencrypted composite table f’ to another unencrypted composite table f

10

=A9.create().cursor().fetch()

11

=file("D:\\append3.ctx")

 

12

=A11.create(#EID,NAME,DEPT,SALARY;;"123":"11")

Create an encrypted base table for the composite table

13

=demo.cursor("select EID,NAME,DEPT,SALARY from EMPLOYEE where EID<5 order by  EID")

 

14

=A12.append(A13)

Append cursor records to the entity table

 

15

=A11.append(A5,"123")

Append unencrypted composite table f’ to encrypted composite table f

16

=A11.create(;;"11").cursor().fetch()

 

arguments()

Description:

Return a list of the current dfx file’s argument names.

Syntax:

arguments()

Note:

The function returns a list of the current dfx file’s argument names.

Return value:

A sequence

Example:

 

A

 

1

=arg1+" world!"

 

2

=arg2+88

 

3

=arguments()

Return a list of the current dfx file’s argument names