key()

Read(1993) Label: key,

Here’s how to use key() function.

r .key()

Description:

Get the primary key value of a record.

Syntax:

r.key(Fi,…)

Note:

The function gets the primary key value of record r according to key Fi. If Fi is omitted, return the basic key values. If the key isn’t set for r, return null. If it is a one-field key, just return the single key value; and with a composite key, return a sequence of values.

Parameter:

r

A record

Fi

Key

Return value:

A record’s primary key

Example:

 

A

 

1

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

 

2

=A1(1).key()

1; return null because A1 doesn’t set a key.

3

=A1.keys(EID)

Set EID field as the key.

4

=A1(1).key()

1; return the primary key value of the first record.

5

=A1.keys(EID,DEPT)

Set EID&DEPT fields as the key.

6

=A1(1).key()

[1,R&D]; the primary key value is a sequence because the key consist of two fields.

7

=A1(1).key(DEPT)

R&D; get the value of a specified key field.

Related function:

T.keys()

v.v()