Description:
Join up a cursor and an entity table by the foreign key.
Syntax:
cs.joinx(C:…,T:K:…,x:F,…;…;…;n)
Note:
The function matches the foreign key fields C,… in cursor cs with the key K in entity table T, which is ordered by K, to find the corresponding record in T, and makes the record’s expression x a new field F and adds it to cs to generate a new cursor. The value corresponding to a mismatched record will be recorded as null.
Option:
@i |
Discard the records whose foreign key values can’t be matched |
@d |
When parameters x:F are absent, discard the records whose foreign key values are matching |
@q |
Speed up the matching action according to a certain order when the cursor contains a relatively small amount of data or it is a sequence cs Speed up the join when the cursor contains relatively small amount of data or is a sequence |
@u |
Speed up the matching operation by shuffling records in the cursor |
Parameter:
cs |
A cursor/multicursor |
C |
cs’s foreign key |
T |
An entity table |
K |
The entity table’s key; it is treated as row number when written as # |
x |
An expression of the field of T |
F |
Name of the field of expression x |
n |
Number of buffer rows |
Return value:
A cursor
Example:
|
A |
|
1 |
=demo.cursor("select EID,NAME,DEPT,SALARY from EMPLOYEE where EID<10 order by EID" ) |
Return a data retrieval cursor:
|
2 |
=file("D:\\PERFORMANCE3.ctx") |
|
3 |
=A2.open() |
Open an entity table:
|
4 |
=A1.joinx(EID,A3:EMPLOYEEID,BONUS+1:SALARY1;5) |
Normal join; use null to represent the records whose foreign key values are mismatched. |
5 |
=A4.fetch() |
|
6 |
=A1.joinx@i(EID,A3:EMPLOYEEID,BONUS+1:SALARY1;5) |
Discard the records whose foreign key values are mismatched. |
7 |
=A6.fetch() |
|
8 |
=A1.joinx@d(EID,A3:EMPLOYEEID;5) |
Keep records whose foreign key values are mismatched when parameters x:F are absent. |
9 |
=A8.fetch() |
|
10 |
=A1.joinx@q(EID,A3:EMPLOYEEID,BONUS+1:SALARY1;5) |
Retrieve corresponding records efficiently from the entity table in order to match with the foreign key. |
11 |
=A10.fetch() |
|
12 |
=A1.joinx(EID,A3:#,BONUS+1:SALARY1;5) |
Take A1’s EID as the record number to join with A3’s records. |
13 |
=A12.fetch() |
|