CS.merge()

Read(709) Label: merge, cursor sequence,

Description:

Merge data of the member cursors of a sequence of cursors and return a multicursor.

Syntax:

CS.merge(xi,…)

Note:

CS is a sequence of cursors ordered by [xi,…], and from each cursor a sequence of records can be output. The function merges the records of these cursors by the expression xi and returns a multicursor.

 

Members of the cursor sequence must be of the same structure. If members are multicursors, they must have the same number of parallel cursors and be segmented synchronically.

 

This is a delayed function.

Parameter:

CS

A sequence of cursors.

xi

An expression. If performing merge by multiple fields, use comma to separate them, for example, x1,x2...

Option:

@u

Union operation. Remove the duplicate records from the resulting cursor obtained by unioning the cursor members of CS in certain order. By default, the duplicate records are included.

@i

Intersection operation. Return a cursor composed of common members of members of CS, the sequence of cursors.

@d

Difference operation. Create a new cursor by removing members of CS2&CSn from CS1.

@0

Put records with null values at the end.

@x

Only merge distinct records in member cursors.

Return value:

Multicursor

Example:

 

A

 

1

=connect("demo").cursor("SELECT  top 10 EID,NAME,DEPT,GENDER  FROM employee ")

Return a cursor whose data is as follows:

2

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM employee where GENDER='M' ")

Return a cursor whose data is as follows:

3

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM  employee where DEPT='Sales' ")

Return a cursor whose data is as follows:

4

=[A1,A2,A3]

Return a sequence of cursors.

5

=A4.merge(EID)

Merge records in the cursor members of the sequence in order according to EID field.

6

=A5.fetch()

Fetch data from cursor A5 (it would be better to fetch data in batches when a huge amount of data is involved):

Use @u option to perform union operation:

 

A

 

1

=connect("demo").cursor("SELECT  top 10 EID,NAME,DEPT,GENDER  FROM employee ")

Return a cursor whose data is as follows:

2

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM employee where GENDER='M' ")

Return a cursor whose data is as follows:

3

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM  employee where DEPT='Sales' ")

Return a cursor whose data is as follows:

4

=[A1,A2,A3]

Return a sequence of cursors.

5

=A4.merge@u(EID)

Use @u option to merge records of member cursors in the sequence in order according to EID field, during which dulicate members are discarded.

6

=A5.fetch()

Fetch data from cursor A5:

 

Use @i option to perform intersection operation:

 

A

 

1

=connect("demo").cursor("SELECT  top 10 EID,NAME,DEPT,GENDER  FROM employee ")

Return a cursor whose data is as follows:

2

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM employee where GENDER='M' ")

Return a cursor whose data is as follows:

3

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM  employee where DEPT='Sales' ")

Return a cursor whose data is as follows:

4

=[A1,A2,A3]

Return a sequence of cursors.

5

=A4.merge@i(EID)

Use @i option to get the intersection and returna cursor containing common records of the member cursors in the sequence.

6

=A5.fetch()

Fetch data from cursor A5:

 

Use @d option to perform difference operation:

 

A

 

1

=connect("demo").cursor("SELECT  top 10 EID,NAME,DEPT,GENDER  FROM employee ")

Return a cursor whose data is as follows:

2

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM employee where GENDER='M' ")

Return a cursor whose data is as follows:

3

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM  employee where DEPT='Sales' ")

Return a cursor whose data is as follows:

4

=[A1,A2,A3]

Return a sequence of cursors.

5

=A4.merge@d(EID)

Use @d option to perform the difference operation that removes records of cursor A2 and cursor A3 from cursor A1 and forms a new cursor.

6

=A5.fetch()

Fetch data from cursor A5:

 

Use @x option to get non-duplicate members from the sequence of cursors to form a new sequence:

 

A

 

1

=connect("demo").cursor("SELECT  top 10 EID,NAME,DEPT,GENDER  FROM employee ")

Return a cursor whose data is as follows:

2

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM employee where GENDER='M' ")

Return a cursor whose data is as follows:

3

=connect("demo").cursor("SELECT  top 5 EID,NAME,DEPT,GENDER  FROM  employee where DEPT='Sales' ")

Return a cursor whose data is as follows:

4

=[A1,A2,A3]

Return a sequence of cursors.

5

=A4.merge@x(EID)

Use @x option to perform the difference operation that gets non-duplicate records from members cursors of the sequence to form a new sequence.

6

=A5.fetch()

Fetch data from cursor A5:

Related function:

A.merge()