A.p find()

Description:

Get the sequence number of a record by its primary key.

Syntax:

A.pfind(k)

Note:

The function gets the sequence number of a record whose primary key value is k. Return null if the key isn’t set or the eligible record can’t be found. When parameter A has a time key, among records that have same basic key values and where the time key value is not greater than the specified k value, find the record whose time key value is the largest. If there isn’t time key value in the primary key, take the time calculated through now() function, which is the latest time.

Parameter:

A

Record sequence/table sequence

k

Primary key; multiple field values from a composite primary key will be presented in sequence [k1,k2,…] or (k1,k2,…)

Option:

@b

Enable the binary search which requires that A must be ordered by the key, otherwise the result will be wrong

@s

Return the opposite number of an insertable position number when the eligible record cannot be found

@0

Return 0 when there isn’t such a record corresponding to the key

Return value:

The sequence number of the eligible record

Example:

 

A

 

1

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

2

=A1. keys (NAME,DEPT)

 

3

=A1.pfind(["Alexis","Sales"])

7; use a sequence to represent the value of a multi-field primay key to do the search.

4

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

This table sequence is ordered by EID field.

5

=A4.keys(EID)

 

6

=A4.pfind@b(3)

3; @b is used to enable the binary search in order to speed up the computation.

7

=A4.pfind@s(501)

-501; cannot find record whose EID is 501 and return the opposite number of the position where the insertion is planned.

8

=demo.query("select NAME,STATE,HIREDATE from EMPLOYEE where GENDER='M'")

9

=A8.keys@t(STATE,HIREDATE)

Set STATE as the basic key, and HIREDATE as the time key.

10

=A8.pfind(["Florida",date("2006-03-12")])

197, which is the sequence number of the record whose time key value is the largest among records where time key values are not greater than 2006-03-12 and that have same STATE values.

11

=A8.pfind("Florida")

232; the time key value is the latest date calculated through now() function.

12

=A8.pfind@0("OK")

0.

Related function:

A.find()