delete()

Read(207) Label: delete,

Here’s how to use delete() function.

T .delete()

Description:

Delete specified records from a table sequence.

Syntax:

T.delete(k)

Delete the kth record

T.delete(p)

Delete the records whose sequence numbers exist in p

T.delete(A)

Delete the records that exist in A

Note:

The function deletes the specified records from table sequence T, and automatically updates the index, if any, and checks distinctness. The deleted records will be always saved in the delete buffer.

Parameters:

T

A table sequence

k

A positive integer, which specifies the position of a record to be deleted

p

An integer sequence with the length of n, which specifies the positions of the records to be deleted

A

A sequence, which specifies the records to be deleted

Options:

  @n  Return the deleted record or a record sequence of the deleted records

Return value:

The table sequence T, some records of which have been deleted

Example:

 

A

 

1

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

 

2

=A1.delete(1)

Delete the first record

3

=A1.delete([2,4,6])

Delete the second, the forth and the sixth records.

4

=A1.select(EID>5)

 

5

=A1.delete(A4)

Delete the records whose EID is more than 5.

6

=A1.delete@n(1)

Return the deleted record

Note:

We use the store address, instead of the field names or field values, to judge whether the records specified by A exist in T. So to delete the specified records , we generally use the function T.delete(T.select(…)) to locate them.

Related functions:

T.modify()

T.insert()

A.delete()

A. delete()

Description:

Delete specified members from a sequence.

Syntax:

A.delete(k)

Delete the kth member

A.delete(p)

Delete the members whose sequence numbers exist in p

Note:

The function deletes the kth member or the members whose sequence numbers exist in p from sequence A, and automatically updates the index, if any, and checks distinctness.

Parameters:

A

A sequence

k

A positive integer that indicates the position of a member to be deleted in the sequence

p

An integer sequence with the length of n that specifies the positions of the members to be deleted

Options:

@n

Return the deleted record or a record sequence of the deleted records

Return value:

A sequence

Example:

 

A

 

1

=["a","c","d","e","f"]

 

2

=A1.delete([2,4,5])

[a,d]

3

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

 

4

=A3.delete@n(2)

Return the deleted record

Related functions:

A.insert()

A.modify()

T.delete()

T.delete( P )

Description:

Delete specified record(s) from acomposite table.

Syntax:

T.delete(P)

Note:

The function deletes from entity table T the records that matches key values of record sequence P. If T has an index, then update it automatically. If T is the base table having an attached table, delete records having same dimensions from the attached table.

Parameters:

T

An entity table

P

A record sequence having same structure as T

Options:

@n

Return the deleted record(s)

Example:

 

A

 

1

=file("D:\\emp3.ctx")

 

2

=A1.create(#EID,NAME;EID)

Create a composite table where EID field is the key by which records are segmented

3

=demo.cursor("select EID,NAME from employee where EID< 10")

 

4

=A2.append(A3)

Append data to the base table

5

=A2.attach(table3,GENDER)

Add an attached table to the base table

6

=demo.cursor("select EID,GENDER from employee where EID< 10")

 

7

=A5.append(A6)

Append cursor records to the attached table

8

=demo.query("select EID,GENDER from employee where EID =3 ")

Return records of the table sequence where EID is 3

9

=A5.delete(A8)

Delete the records where EID is 3 from entity table table3

10

=demo.query("select EID,NAME from employee where EID =2")

Return records in the table sequence where EID is 2

11

=A2.delete@n(A10)

Return the deleted record

 

T.delete( P )

Description:

Delete specified records from a memory table.

Syntax:

T.delete(P)

Note:

The function matches memory table T’s primary key with primary key values of record sequence P and deletes from T the matching records, during which T’s primary key keeps its order. Will automatically update the index if T has one.

Parameters:

T

A memory table

P

A records sequence having the same structure as T

Options:

@n

Return the deleted records

Return value:

A memory table

Example:

 

A

 

1

=demo. cursor ("select EID,NAME,GENDER from employee where EID< 10")

Return a cursor

2

=A1.memory()

Return a memory table

3

=A2.keys(EID)

 

4

=demo.query("select EID,NAME,GENDER from employee where EID =3 ")

Return records in the table sequence where EID is 3

5

=A2.delete(A4)

Delete records where EID is 3

6

=demo.query("select EID,NAME,GENDER from employee where EID =5 ")

Return records in the table sequence where EID is 5

7

=A2.delete@n(A6)

Return the deleted record

 

T.delete(P)

Description:

Delete specified records from a cluster table.

Syntax:

T.delete(P)

Note:

The function matches cluster table T’s primary key with primary key values of record sequence P and deletes from T the matching records. Will automatically update the index if T has one. Only records in a distributed cluster composite table can be deleted.

Parameters:

T

A cluster table

P

A record sequence of same structure as T

Example:

 

A

 

1

=file@0@z("emp10.ctx",["192.168.0.118:8281"])

 

2

=A1.create()

Open a distributed cluster composite table

3

=demo.query("select EID,GENDER from employee where EID =3 ")

Return records of the table sequence where EID is 3

4

=A2.delete(A3)

Delete records from entity table table3 where EID is 3