• esProc
Tutorial
Function Reference
Sample Program
Code Reference
User Reference
External Library Guide
Data File Tool Manual
DQL Tutorial
Cluster Server Manager Manual
SPL Command Executor Manual
• YModel
User Reference
JSON-style Parameter Guide
• Official Website

# 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 records whose sequence numbers exist in p T.delete(A) Delete records that exist in sequence 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.

Parameter:

 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

Option:

 @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 function:

## A. delete()

Description:

Delete specified members from a sequence.

Syntax:

 A.delete(k) Delete the kth member A.delete(p) Delete members whose sequence numbers exist in p; count backward when a member of sequence p is less than 0

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.

Parameter:

 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

Option:

 @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 5 =["a","c","d","e","f"].delete([3,-5]) Count backward to get the value  [c,e,f] since one member of the sequence parameter is less than 0

Related function:

## T.delete( P )

Description:

Delete specified record(s) from an entity table.

Syntax:

T.delete(P)

Note:

The function deletes from entity table T the records that match key values of record sequence P. The primary key should be in ascending order. If T is the base table having an attached table, delete records having same dimensions from the attached table.

Parameter:

 T An entity table P A record sequence having same structure as T

Option:

 @n Return deleted record(s) from the record sequence

Example:

 A 1 =file("emp.ctx") An existing composite table file 2 =A1.open() Open the composite table’s base table 3 =A2.cursor().fetch() Get data in the base table: 4 =A2.attach(table3) Return the base table’s attached table table3 5 =A4.cursor().fetch() Get data of the attached table 6 =create(EID,NAME).record([1,"aaa",21,"bbb"]) Return a table sequence 7 =A2.delete@n(A6) Delete records from both the table sequence and the base table where the former’s key values are contained in the latter’s corresponding key values; @n option is used to return the deleted record 8 =A2.cursor().fetch() Check the base table to see that the record where key EID value is 1 is deleted 9 =A4.cursor().fetch() Check the attached table to see that the record with same dimension value is deleted

## T.delete( P )

Description:

Delete one or more specified records from a pseudo table.

Syntax:

T.delete(P)

Note:

The function deletes records of record sequence P from pseudo table T by comparing their primary keys.

Parameter:

 T A pseudo table P A record sequence having the same structure with T

Option:

 @n Return the deleted records

Example:

 A 1 =create(file).record(["D:/file/pseudo/Employee.ctx"]) 2 =pseudo(A1) Generate a composite table object 3 =create(Dept,AvgSalary).record(["HR",7000,"CSD",6018.04]) Return a table sequence 4 =A2.delete@n(A3) Delete records from A2’s pseudo table according to table sequence A3’s primary key values, and return the deleted records 5 =A4.import()