T.k eys()

Read(1641) Label: table sequence, set a key,

Description:

Set key for a table sequence.

Syntax:

T.keys(Ki,…)

Note:

The function sets Ki,… as the key of the table sequence T. When parameter Ki is absent, delete T’s key. A T.create() operation will copy the key at the same time.

Parameter:

T

A table sequence.

Ki

The key of table sequence T.

Option:

@t(Ki,…,KT)

Set the last parameter KT as the time key, and make all other parameters the base keys.

Return value:

Table sequence

Example:

 

A

 

1

=demo.query("select EID,NAME,DEPT,SALARY,HIREDATE from EMPLOYEE order by EID asc,DEPT asc")

Return a table sequence:

2

=A1.keys(EID,DEPT)

Set EID field and DEPT field as A1’s key:

In a esProc result set, a field whose name is marked by  is a key field.

3

=A1(1).key()

Get base key values in table A1’s first record and return [1, "R&D"].

4

=A1.keys()

Remove the key as the parameter is absent.

5

=A1(1).key()

null.

6

=A1.keys@t(EID,DEPT,HIREDATE)

Set EID and DEPT as A1’s base keys and HIREDATE as the time key:

7

=A1.create()

Copy table A1’s structure as well as its key.

8

=A7.insert(0,1,"Jack","HR",3000,date("2022-03-09"))

 

Add a record to table A7:

9

=A7(1).key()

base keyGet base key values in table A7’s first record: [1,"HR"]

Related functions:

r.key()

v.v()