Maintenance of Table Sequences & Record Sequences

This chapter lists code examples of handling data maintenance in table sequences and record sequences, including Copy a table sequence entirely, Insert one or multiple null or non-null records into a table sequence, Remove one or multiple records from a table sequence, Modify field values of one or multiple records, Modify the record at a specified position and fill up the position automatically if it is beyond range, Add a calculated column to a table sequence, Create a new table sequence based on the specified table sequence/record sequence, Combine table sequences or split a table sequence, Insert a sequence into the newly-created table sequence to generate new records, Get field values of a table sequence/record sequence and join them into a sequence, Add sequence members into a table sequence/record sequence as field values, Add sequence members to a table sequence/record sequence vertivally as field values, and Copy field values of a table sequence/record sequence into another table sequence/record sequence.

Copy a table sequence entirely

 

A

 

1

=demo.query("select NAME,EVENT, SCORE from GYMSCORE")

 

2

=A1.derive()

Copy the table sequence entirely

3

=A1.to(,)

Copy as a record sequence only

 

Insert one or multiple null or non-null records into a table sequence

 

A

 

1

=demo.query("select NAME, EVENT,SCORE from GYMSCORE")

 

2

>A1.insert(2)

Insert a null record before the second record

3

>A1.insert(0:10,~:NAME)

Append 10 records at the end of the table sequence and set the "NAME" field values

Remove one or multiple records from a table sequence

 

A

 

1

=demo.query("select NAME, EVENT, SCORE from GYMSCORE")

 

2

>A1.delete(2)

Remove the second record

3

>A1.delete([4,6,1])

Remove multiple records

4

>A1.delete(A1.select(SCORE<15))

Remove records based on specified conditions

 

Modify field values of one or multiple records

 

A

 

1

=demo.query("select NAME,EVENT, SCORE from GYMSCORE")

 

2

>A1.run(SCORE+2:SCORE)

Modify all the records

3

>A1.select(EVENT=="Vault").run(SCORE+2:SCORE)

Modify some of the records

 

Modify a record at a specified position and fill up the position automatically if the record is beyond range

 

A

 

1

=demo.query("select NAME,EVENT, SCORE from GYMSCORE")

A table sequence

2

=A1.modify(5,"":EVENT,15:SCORE)

Modify the fifth record and fill up the out-of-range positions automatically

 

Add a calculated column to a table sequence

 

A

 

1

=demo.query("select NAME,UNITPRICE, QUANTITY from RECEIPT")

 

2

=A1.derive(UNITPRICE*QUANTITY:Amount)

Add the "Amount" field

 

Create a new table sequence based on the specified table sequence / record sequence

 

A

 

1

=demo.query("select NAME, ABBR, CAPITAL,POPULATION from STATES")

 

2

=A1.new(NAME, ABBR)

Create a new table sequence based on the original one

3

=A1.new(NAME:State, ABBR,CAPITAL:Capital)

Change the field names

 

Combine table sequences or split a table sequence

 

A

 

1

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

 

2

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

 

3

=A1|A2

Concatenate table sequences A1 and A2

 

Insert a sequence into the newly - created table sequence to generate new records

 

A

B

 

1

1

Tom

 

2

2

Jack

 

3

3

Andy

 

4

=create(id,name)

 

 

5

=A4.record([A1:B3])

 

 

 

Get field values of a table sequence / record sequence and join them into a sequence

 

A

B

 

1

1

Tom

 

2

2

Jack

 

3

3

Andy

 

4

=create(id,name)

 

 

5

=A4.record([A1:B3])

 

 

6

=A5.field(2)

 

Return the same sequence as [B1:B3]

 

Add sequence members into a table sequence / record sequence as field values

 

A

B

 

1

1

Tom

 

2

2

Jack

 

3

3

Andy

 

4

=create(id, name).insert(1:3)

 

 

5

=A4.paste@a([A1:B3])

 

 

 

Add sequence members to a table sequence / record sequence vertically as field values

 

A

B

C

 

1

1

2

3

 

2

Tom

Jack

Andy

 

3

=create(id, name).insert(1:3)

 

 

 

4

=A3.modify(1:[A1:C1],~:#1)

 

 

The first column

5

=A3.modify(1:[A2:C2],~:#2)

 

 

The second column

 

Copy field values of a table sequence / record sequence into another table sequence / record sequence

 

A

 

1

=create(name,price)

 

2

=demo.query("select NAME,UNITPRICE, QUANTITY from RECEIPT")

 

3

=A1.modify@r(0:A2)