field()

Read(252) Label: field,

Here’s how to use field() function.

r .field( F )

Description:

Get the value of a specified field in a record.

Syntax:

r.field(F)

Note:

The function gets value of the Fth field in record r, or value of string parameter F. Count backward if F<0. Return null if F exceeds the boundary number of the fields or it does not exist.

Parameters:

r

A record

F

Sequence number of a field, or the string parameter in which a variable can be used to reference the field name.

Return value:

The field value

Example:

 

A

 

1

=demo.query("select * from EMPLOYEE")(1).field(2)

Return the second field value of the first record in table sequence demo.query ("select * from EMPLOYEE")

2

=demo.query("select * from EMPLOYEE")(1).field(-2)

Return the second-to-last field value in the first record of the table sequence demo.query ("select * from EMPLOYEE")

3

=demo.query("select * from EMPLOYEE")(1).field(arg1)

SALARY is the value of variable arg1

4

=demo.query("select * from EMPLOYEE")(1).field(“SALARY”)

 

 

Related functions:

A.field(F)

A.field(F,x)

r.field(F,x)

r .field( F , x )

Description:

Modify a value of the specified field of a record.

Syntax:

r. field(F,x)

Note:

The function modifies the value of the Fth field of record r, or the value of string parameter F, into x. Count backward if F<0. Do not execute if F exceeds the boundary number of the fields or it does not exist.

Parameters:

r

Record

F

Sequence number of a field, or the string parameter in which a variable can be used to reference the field name.

x

Expression whose computing result is the value of the Fth field, or the value of the string parameter F.

Return value:

None

Example:

 

A

 

1

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

2

=A1(1).field(2,"Admin1")

Change the value of the 2nd field of the record 1 to Admin1

3

=A1(1).field(-1,10000)

Modify the value of record 1’s last field into 10,000

4

>arg1="SURNAME"

 

5

=A1(1).field(arg1,"Lily")

Modify the value of record 1’s SURNAME field into Lily

Related functions:

A.field(F)

A.field(F,x)

r.field(F)

A .field( F )

Description:

Get values of a specified field of a sequence.

Syntax:

A.field(F)

Note:

The function loops through parameter A to get the value of the Fth field from each record, or the value of every string parameter F, and returns a sequence consisting of these values. Count backward if F<0. Return null if F exceeds the boundary number of the fields or it does not exist.

Parameters:

A

A sequence

F

The sequence number of a field, or the string parameter in which a variable can be used to reference the field name.

Options:

@r

When the return value is a record or record sequence, loop its members iteratively to get desired values

Return value:

A sequence

Example:

 

A

 

1

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

 

2

=A1.field(2)

Return a sequence composed of values of the second field.

3

=A1.field(-2)

Return a sequence comprising values of the second-to-last field

4

=A1.field("NAME")

Return a sequence composed of values of NAME field

5

>arg1="NAME"

 

6

=A1.field(arg1)

Same as A4

7

=demo.query("select * from EMPLOYEE where EID < 20")

 

8

=A7.group(STATE;~.avg(SALARY):avg,~:group)

9

=A8.field@r(3)

After A8’s 3rd column is returned, go on to return the 3rd column of the return value

 

Related functions:

r.field(F)

r.field(F,x)

A.field(F,x)

A .field( F , x )

Description:

Modify the value of a specified field in a sequence.

Syntax:

A. field(F,x)

Note:

The function assigns members of sequence x sequentialy to values of Fth field in sequence A, or values of string parameter F. Count backward if F<0. Do not execute if F exceeds the boundary number of the fields or it does not exist.

Parameters:

A

A sequence

F

Sequence number of a field, or the string parameter in which a variable can be used to reference the field name.

x

A sequence whose length is equal to the number of values in Fth field, or a single value, which can be considered as a sequence in which members have the same value and their number is equal to the number of values in Fth field.

Return value:

None

Example:  

 

A

 

1

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

 

2

=A1.field(9,8000)

Modify the value of the ninth field; parameter x is a single value, and it will be regarded as the sequence [8000,8000,8000]

Here’s A1’s result:

3

=A1.field("SALARY",7000)

Modify all values of SALARY field into 7000

4

>arg1="SALARY"

 

5

=A1.field(arg1,7000)

Same as A3

6

=A1.field(9,[8000,6500,9000])

Here parameter x is a sequence, and this is A1’s result:

Related functions:

r.field(F)

A.field(F)

r.field(F,x)