UpdateTable example
The UpdateTable function in the class BlueCieloECM.GcfSupport retrieves data from a specified remote vault and merges the received data into a local table. For a detailed description of this function, see UpdateTable function.
A convenient point to call this function is upon the creation of a GCF briefcase. The following example uses two tables, Test1 (row ownership) and Test2 (additive replication) that are updated when the scheduled transfer of briefcases takes place:
Dim bTableUpdateDone
Sub BrcEvent_BeforeCreate (Briefcase, Abort) 'The export processor sets CurrentTransfer.
If IsArray (Vault.Argument ("CurrentTransfer")) Then 'Check CurrentTransfer for a scheduled transfer
If Vault.Argument ("CurrentTransfer")(5) Then 'bTableUpdateDone is initially empty when the scheduled transfer starts. 'By setting it to True during processing, repeated updates 'in a single update run are avoided.
If Not bTableUpdateDone = True Then
Set objGCFSupport = AMCreateObject("BlueCieloECM.GcfSupport", False)
objGCFSupport.UpdateTable Vault.Table ("Test1"), "GCF2", _
Array ("Key1", "Key2"), "Owner"
objGCFSupport.UpdateTable Vault.Table ("Test2"), "GCF2", Array ("Key"), ""
Set objGCFSupport = Nothing
bTableUpdateDone = True
End If
End If
End If
End Sub
Note The names of arguments of the Vault.Argument property are case-sensitive.
The Test1 table contains the following columns:
- Key1: First column of the primary key
- Key2: Second column of the primary key
- Data1: First data column
- Data2: Second data column
- Owner: The column determining ownership
The Test2 table contains the following columns:
- Key: The primary key
- Data: The data column
The data in Test1 is replicated in the preceding example by the first call to UpdateTable. The call specifies the combination of Key1 and Key2 as the primary key and Owner as the owner column.
The data in Test2 is replicated in the preceding example by the second call to UpdateTable. The call specifies Key as the primary key and no owner column.
Assume the following table data before update.
Key1 |
Key2 |
Data1 |
Data2 |
Owner |
---|---|---|---|---|
K1.1 |
K1.2 |
D1.1 |
D1.2New |
GCF1 |
K2.1 |
K2.2 |
D2.1 |
D2.2 |
GCF2 |
K3.1 |
K3.2 |
D3.1 |
D3.2 |
GCF2 |
Key |
Data |
---|---|
K1 |
D1 |
K2 |
D2New |
Key1 |
Key2 |
Data1 |
Data2 |
Owner |
---|---|---|---|---|
K1.1 |
K1.2 |
D1.1 |
D1.2 |
GCF1 |
K2.1 |
K2.2 |
D2.1New |
D2.2 |
GCF2 |
K4.1 |
K4.2 |
D4.1 |
D4.2 |
GCF2 |
Note The row containing K3.1 has been deleted.
Key |
Data |
---|---|
K1 |
D1New |
K2 |
D2 |
K3 |
D3 |
The data in the tables in GCF1 will be as follows after the two calls to UpdateTable:
Key1 |
Key2 |
Data1 |
Data2 |
Owner |
---|---|---|---|---|
K1.1 |
K1.2 |
D1.1 |
D1.2New |
GCF1 |
K2.1 |
K2.2 |
D2.1New |
D2.2 |
GCF2 |
K4.1 |
K4.2 |
D4.1 |
D4.2 |
GCF2 |
Key |
Data |
---|---|
K1 |
D1New |
K2 |
D2New |
K3 |
D3 |