T. modify()

Description:

Modify field values in a table sequence.

Syntax:

T.modify(k,xi:Fi,…)

Modify the kth record, which is equal to T(k).modify(xi:Fi,…) .

T.modify(k:A,xi:Fi,…)

Modify the records from the kth record to the (k+|A|-1)th record.

Note:

The function modifies one or more records at the specified position(s). Automatically update the index, if any, and check distinctness.

Parameter:

k

The position at which the record will be modified. If k exceeds the limit, then append a new record in the end.

xi

The value of Fi field to be modified.

Fi

Name of the field of the record which will be modified. If Fi is omitted, then modify the ith field of T.

T

A table sequence.

A

A sequence or an integer; If A is an integer, then it is equal to to(A) .

Option:

@n

Return the newly-modified record or sequence.

@r(k:A)

Modify table sequence T using sequence A from the kth record according to the order of the fields.

@f(k:A)

Modify table sequence T using sequence A from the kth record; only the common fields are modified.

Return value:

Return the updated record or sequence

Example:

 

A

 

1

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

2

=A1.modify(1,"Sales",5)

Modify the first and the second fields of the first record.

3

=A1.modify(2,6:MANAGER)

Modify the MANAGER field of the second record.

4

=A1.modify@n(2:1,"AAA":DEPT,76:MANAGER)

Return the modified second record.

5

=create(DeptName,ManagerID)

 

 

 

6

=A5.modify(1:A1,DEPT:DeptName,MANAGER:ManagerID)

Append a new record in the end because 1 exceeds the limit.

7

=A1.delete(A1.select(MANAGER>5))

 

8

=A5.modify@r(1:A7)

Modify A5 using A7 from the first record.

9

=create(DeptName,MANAGER)

 

10

=A9.modify@f(1:A7)

Modify MANAGER field only.

Related function:

r.modify()

T.insert()

T.delete()

A.modify()