v()

Read(2189) Label: referencing field, primary key,

Here’s how to use v() function.

v.v()

Description:

Get the primary key value of the record pointed by a referencing field.

Syntax:

v.v()

Note:

If v is a record with a key set, the function will return its primary key value; if v is a record without a key set, the function will return a sequence composed of all its field values; if v isn’t a record, the function will return v itself.

 

This function is used to get the primary key value of the record pointed by a referencing field. Since a referencing field can switch between a referenced record and its key value through the switch() function, the v() function can be used to distinguish a record from a key value.

 

v may be a record, a sequence or a number.

Parameter:

v

A record, a sequence or a number

Return value:

The primary key value of the record pointed by a referencing field

Example:

 

A

 

1

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

 

2

=A1(1).EID.v()

1; because the value of the EID field is a single number, the value itself is returned.

3

=A1(1).v()

[1, RebeccaMooreFCalifornia1974-11-202005-03-11R&D7000]; return a sequence composed of all field values of A1(1) because A1 doesn’t set a key.

4

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

 

5

=A1.switch(DEPT,A4:DEPT)

Switch the DEPT field into a referencing field pointing to the record of DEPARTMENT.

6

=A1(1).DEPT.v()

2; here, DEPT is a reference field whose value is record, therefore, the primary key value of the referenced record will be returned.

7

=A4.keys(DEPT,MANAGER)

Set DEPT and MANAGER as the key of A4.

8

=A1(1).DEPT.v()

[R&D,2]; return the key value of the record pointed by "DEPT"; since there are two key fields, a sequence of primary key value will be returned.

Related function:

r.key()

T.keys()