create()

Read(330) Label: create,

Here’s how to use creat() function.

create ( F i ,… )

Description:

Create an empty table sequence.

Syntax:

create(Fi,…)

Note:

The function creates an empty table sequence taking Fi,… as its fields.

Parameters:

Fi

Field name

Return value:

An empty table sequence

Example:

 

A

 

1

=create(id,name,sex)

create(# Fi ,…)

Description:

Create an empty table sequence with one or more keys set.

Syntax:

create(#Fi,…) 

Note:

The function creates an empty table sequence that has the fields Fi,…. A field name headed by the sign # is a key.

Parameters:

Fi

Field name

Return value:

Empty table sequence

Example:

 

A

 

1

=create(#id,#name,gender)

id field and name field are keys

f.create()

Description:

Open a composite table.

Syntax:

f.create()

Open an unencrypted composite table

f.create(;;p)

Open an encrypted composite table

Note:

The function opens a composite table. If parameter p is a write password, you can retrieve or update the composite table or add an attached table; if it is a read password, the composite table is read-only but can’t be modified. If an encrypted composite table has both the write password and the read password, only one of them needs to be present as needed. The composite table file f can be a file group, in which the files must have same passwords.

Parameters:

f

A composite table file

p

Write password/read password

Options:

  @o  Won’t merge data retrieved from every file in a file group; peform merge by default

Return value:

A composite table

Example:

 

A

 

1

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

 

2

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

Create an encrypted composite table

3

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

 

4

=A3.create(#EID,NAME,GENDER)

Create an unencrypted composite table

5

=A3.create()

Open an unencrypted composite table file

6

=A1.create(;;"12")

Use read password to retrieve an encrypted composite table that has both the write password and read password

7

=A1.create(;;"@!*123")

Use write password to open an encrypted composite table that has both the write password and read password

8

=file(["D:\\emp2.ctx","D:\\emp1.ctx","D:\\emp1.ctx"])

Unencrypted file group

9

=A8.create().cursor().fetch()

Perform an ordered merge by default

10

=A8.create().cursor().fetch()

Won’t perform an ordered merge with @o option

f.create()

Description:

Open a cluster composite table.

Syntax:

f.create()

Open an unencrypted cluster composite table

f.create(;;p)

Open an encrypted cluster composite table

Note:

The function opens a cluster composite table. For a cluster composite table, the file type determines the type of its cluster base table. Distributed cluster files have a segmental cluster base table and duplicate cluster files have a duplicate cluster base table. If parameter p is a write password, you can retrieve or update the composite table or add an attached table; if it is a read password, the composite table is read-only but can’t be modified. If an encrypted composite table has both the write password and the read password, only one of them needs to be present as needed.

Parameters:

f

A cluster table file

p

Write password/read password

Return value:

A cluster composite table object

Example:

 

A

 

1

=file@0("emp1.ctx",["192.168.0.116:8281","192.168.0.129:8281"])

Generate a duplicate cluster file

2

=A1.create()

Create a duplicate cluster base table

3

=file@0("employee2.ctx",["192.168.31.72:8281"])

 

4

=A3.create(;;"12")

Use read password to retrieve an encrypted composite table that has both the write password and read password

5

=A3.create(;;"@!*123")

Use write password to open an encrypted composite table that has both the write password and read password

 

f.create( C:b 1 ,…;K:b 2 ;pw:pr )

Description:

Generate a composite table’s base table from a file.

Syntax:

f.create(C:b1,…;K:b2;pw:pr)

Note:

According to file f, the function creates a composite table’s base table (which we’ll simply call the base table) consisting of columns C…; a C preceded by # is a dimension, which should be written in the first place and there can be multiple dimensions. Records in the base table must be ordered by the dimension(s). Parameter b1 is the length of serial byte key and can be omitted. Parameter K is the key according to which the composite table is segmented. If K contains serial byte data, then the first b2 bytes of K’s value are used for segmentation. The extension of a composite table file is ctx.

Parameters:

f

A local file

C

A base table column

b1

The length of serial byte key, which is an integer less than 8; parameter K isn’t a serial byte key when this parameter is absent

K

The key by which the composite table is segmented

b2

The number of bytes, which is an integer less than 8; can be omitted

pw

Write password that can be omitted; if the parameter is absent, the read password must be omitted, too

pr

Read password that can be omitted; if the write password is present, this read password can be omitted

Options:

@u

Won’t compress the base table; by default it will be compressed

@r

Generate a composite table stored by row, which doesn’t support the use of multicursor; a composite table is by default stored by column

@y

Re-create a namesake file even if the file already exists; without the option the program will terminate the execution and report an error

Return value:

A base table

Example:

 

A

 

1

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

 

2

=A1.create(#EID,NAME,GENDER)

Create base table employee1 without the key for ordering records and with EID, NAME and GENDER being the columns, in which EID is the dimension

3

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

 

4

=A3.create(#EID:3,NAME,GENDER;EID:2)

Create a base table in which EID is the key for ordering records and the first two bytes of EID values being used to segment the table and the key value has 3 bytes

5

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

 

6

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

Create a base table that have both the write and read passwords

7

=A1.create@y(#EID,NAME,GENDER)

Re-create a namesake file; error will be reported if @y option is absent

f.create( C:b 1 ,…;K:b 2 ;pw:pr;x )

Description:

Generate a cluster composite table’s base table from a distributed file.

Syntax:

f.create(C:b1,…;K:b2;pw:pr;x)

Note:

According to file f, the function creates a cluster composite table’s base table (which we’ll simply call the base table) consisting of columns C…; a C preceded by # is a dimension; there can be multiple dimensions. Records in the base table must be ordered by the dimension(s). Parameter b1 is the length of the serial byte key. Parameter K is the key by which the composite table is segmented. If K is a serial byte field, the first b2 bytes of K’s value are used for segmentation.

The function creates a writable cluster base table only to maintain it. It supports a variety of methods including attach, index, reset, append, update, delete; a cluster cursor should first be appended to an empty cluster file when you want to perform append over this file.

Parameters:

f

A distributed file

C

A base table column

b1

The length of serial byte key, which is an integer less than 8; parameter K isn’t a serial byte key when this parameter is absent

K

The key by which the composite table is segmented

b2

The number of bytes, which is an integer less than 8; can be omitted

pw

Write password that can be omitted; if the parameter is absent, the read password must be omitted, too

pr

Read password that can be omitted; if the write password is present, this read password can be omitted

x

A segmentation function; should be present for a write-in operation

Options:

@u

Won’t compress the base table; by default it will be compressed

@r

Generate a composite table file stored by row, which doesn’t support the use of multicursor; a composite table is by default stored by column

@y

Re-create a namesake file even if the file already exists; without the option the program will terminate the execution and report an error

Return value:

A cluster table object

Example:

 

A

 

1

[192.168.31.72:8281]

 

2

=file@z("salespart.ctx", A1)

 

3

=A2.create()

 

4

=A3.cursor()

Create a cluster cursor

5

=file@zw("salespart1.ctx",["192.168.31.72:8281"])

s The writable distributed file salespart1.ctx to be opened doensn’t exist

6

=A5.create(#EID,Name,OCount;;"@!*123":"12")

Create a cluster base table that have both the write and read passwords

7

>A6.append(A4)

Append A4’s cluster cursor to A6’s cluster base table

8

=A6.cursor().fetch()

 

9

=file@n("D:\\1\\EmpCTX.ctx",A1)

EmpCTX.ctx consists of several fields – EID, Name, Dept and Age, in which EID is the serial byte key

10

=A9.create()

 

11

=A10.cursor()

Create a cluster cursor

12

=file@wz("EmpCTX2.ctx",A1)

 

13

=A12.create(#EID:4,Name,Dept,Age;EID:3)

Create a base table where EID is the serial byte key , whose length is 4, and its first 3 bytes are the key by which records are segmented

14

>A13.append(A11)

Append A11’s cluster cursor to A13’s cluster base table

15

=A13.cursor().fetch()

 

16

=file@zw("salespart2.ctx",["192.168.31.72:8281"])

Salespart2.ctx doesn’t exist; for generating a writable distributed file

17

=A5.create(#EID,Name,OCount;;"@!*123":"12";EID%2+1)

Create a cluster table with two patitions whose number begins with 1

 

T .create()

Description:

Create an empty table sequence by duplicating the data structure of table sequence T.

Syntax:

T.create()

Note:

If table sequence T has a key, then duplicate the key at the same time.

Parameters:

T

A table sequence

Return value:

A new empty table sequence

Example:

Ø  Create from a normal table sequence

 

A

 

1

=demo.query("select top 1 * from DEPARTMENT")

2

=A1.create()

Create an empty table sequence A2 through "=A1.create ()", and this empty table sequence has the same data structure as table sequence A1. They are all composed of field DEPT and field MANAGER.

Ø  Copy the key and descriptor

 

A

 

1

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

 

2

=A1.keys(DEPT)

 

3

=A1.create()

Create a empty table sequence that has not only the same data structure, but also the same key, as table sequence A1

r .create()

Description:

Create a table sequence by copying the data structure of a specified record.

Syntax:

r.create()

Note:

If there’s a key defined in record r, then copy the key at the same time.

Parameters:

r

A record

Return value:

A new empty table sequence

Example:

Ø  Generate an empty table sequence from an average record

 

A

 

1

=demo.query("select top 1 * from DEPARTMENT")

2

=A1(1).create()

Use “=A1(1).create()” to generate an empty table sequence A2 that has the same data structure as the record “A1(1)”. Both consist of DEPT field and MANAGER field.

Ø  Generate an empty table sequence from a record with the key and the descriptor

 

A

 

1

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

 

2

=A1.keys(DEPT)

 

3

=A1(1).create()

Generate an empty table sequence by copying the data structure of the record A1(1) and the key