Table Object
The Table object represents a lookup list table in the current vault.
Table Object Properties
The Table object provides the following properties, all of which are read-only.
DBConnection Property
An ADO connection object. Read-only.
Syntax
DBConnection As Object
ColumnsInfo Property
A two-dimensional array of table data. Read-only.
Syntax
ColumnsInfo As Variant
DisplayName Property
The Display Name of the table as entered in Configurator. Read-only.
Syntax
DisplayName As String
Name Property
Returns the name of the current object. Depending on the object type, this property returns the display name of the object or it returns the internal name and may be read-only.
Syntax
Name As String
Remarks
If the current object is a Package, it must be in the Open status to set the value.
If the current object is a User, this property is the short name of the user as stored in the user's Meridian account information and is read-only. This property can be used to specify the recipient's email address and either an empty string or no value set in the Address property. If an email address is specified in Name, it must be surrounded with carets (<>). When used with Microsoft Outlook, the Name property may contain the user's full name or last name and Outlook will attempt to resolve the name to the email address in the default address book.
Type Property
The type of the table as one of hte AS_TQTYPE constants. Read-only.
Syntax
Type As AS_TQTYPE
Table Object Methods
The Table object provides the methods described below.
AddValues Method
Adds values to the current Table object.
Syntax
AddValues([Columns], [Values])
Name | Description |
---|---|
Columns |
Optional names of columns to add to the table. |
Values |
Optional values to add to the table. |
Clean Method
Removes all rows from the current Table object.
Syntax
Clean()
Parameters
This method accepts no parameters.
DeleteValues Method
Deletes values from the current Table object.
Syntax
DeleteValues([MatchColumns], [MatchValues])
Name | Description |
---|---|
MatchColumns |
Optional names of columns to delete from the table. |
MatchValues |
Optional values to delete from the table. |
DeleteValuesEx Method
Deletes values from the current Table object.
Syntax
DeleteValuesEx(Where As String, [Parameters])
Name | Description |
---|---|
Where |
SQL expression that specifies the values to delete. |
Parameters |
Optional parameters. |
GetValues Method
Gets values from the current Table object that match the specified criteria. If the query does not match any values, the method returns an empty variant.
Syntax
GetValues([MatchColumns], [MatchValues], [OutColumns], [Distinct], [OrderBy], [FieldsInfo]) As Variant
Name | Description |
---|---|
MatchColumns |
Optional array of column names to match in the table. |
MatchValues |
Optional array of column values to match in the table. The index of each value should match the index of its corresponding column in MatchColumns. |
OutColumns |
Optional array of column names to return in the result. |
Distinct |
If True, returns only the unique values. Optional. |
OrderBy |
Optional array of column names with which to sort the returned values. |
FieldsInfo |
Optional variant array to contain information about the returned columns. The information includes:
For the values of possible data types, see DataTypeEnum in MSDN. For the values of possible column attributes, see FieldAttributeEnum in MSDN. |
Return Value
A 2-dimension variant array with the property values in the second dimension of the array.
Remarks
The GetValues method executes an SQL query with the specified parameters. For example, the following VBScript statement:
Vault.Table("Employees").GetValues(Array("Role","Department"), _ Array("Manager","Engineering"), _ Array("FirstName","LastName"), _ False, "LastName")
Translates into the following SQL query:
SELECT FirstName, LastName FROM Employees WHERE Role='Manager' AND Department='Engineering' ORDER BY LastName
If the FieldsInfo parameter is specified, that array contains information about the returned value array. This can be useful if you want a generic function that can operate with the results of different queries regardless the output columns and the order in which order they were requested. Moreover, using FieldsInfo, you can process results from different tables (or queries to external data sources) without specific knowledge of the column names, which may be named differently in different tables but have the same purpose in the context of your processing.
The following example functions demonstrate the use of FieldsInfo.
' Helper function that finds the index of a ShareName column in the results table. Function FindShareNameIndex(fi) FindShareNameIndex = -1 If IsArray(fi) Then For i = 0 To UBound(fi,1) If fi(0,i) = "ShareName" And fi(1,i) = 202 Then FindShareNameIndex = i Exit Function End If Next End If End Function
Function TestFieldsInfo() Dim fi Dim res res = Vault.Table("GCFShares").GetValues(,,,,,fi) If IsArray(fi) Then Dim sni sni = FindShareNameIndex(fi) TestFieldsInfo = "" For j = 0 To UBound(res,2) TestFieldsInfo = TestFieldsInfo & res(sni,j) & ";" Next Else TestFieldsInfo = fi End If End Function
GetValuesEx Method
Gets values from the current Table object that match the specified criteria. If the query does not match any values, the method returns an empty variant.
Syntax
GetValuesEx([SelectList As String], [Where As String],[GroupBy As String], [Having As String], [OrderBy As String], _ [Parameters], [FieldsInfo]) As Variant
Name | Description |
---|---|
SelectList |
Optional comma-separated list of column names to retrieve values from the table. |
Where |
Optional condition for matching column values to retrieve from the table. |
GroupBy |
Optional column names to group values in the result. |
Having |
Optional aggregate function that is a condition for grouping returned values. |
OrderBy |
Optional comma-separated list of column names with which to sort the returned values. |
Parameters |
Optional value or array of values to be used in a parametric query. The values do not need to be strings. The array should contain a value for each instance of the ? character in the SQL query. |
FieldsInfo |
Optional variant array to contain information about the returned columns. The information includes:
For the values of possible data types, see http://msdn.microsoft.com/en-us/library/ms675318(VS.85).aspx. For the values of possible column attributes, see http://msdn.microsoft.com/en-us/library/ms676553(VS.85).aspx. |
Return Value
A 2-dimension variant array with the property values in the second dimension of the array.
Remarks
The GetValuesEx method is functionally equivalent to GetValues. However, the GetValuesEx method supports parameters in the same order as a standard SQL query. This may be more convenient to use than GetValues if you are already familiar with the SQL language.
If the FieldsInfo parameter is specified, that array contains information about the returned value array. This can be useful if you want a generic function that can operate with the results of different queries regardless of the output columns and the order in which order they were requested. Moreover, using FieldsInfo, you can process results from different tables (or queries to external data sources) without specific knowledge of the column names, which may be named differently in different tables but have the same purpose in the context of your processing.
The following example functions demonstrate the use of FieldsInfo.
' Helper function that finds the index of a ShareName column in the results table. Function FindShareNameIndex(fi) FindShareNameIndex = -1 If IsArray(fi) Then For i = 0 To UBound(fi,1) If fi(0,i) = "ShareName" And fi(1,i) = 202 Then FindShareNameIndex = i Exit Function End If Next End If End Function
Function TestFieldsInfo() Dim fi Dim res res = Vault.Table("GCFShares").GetValues(,,,,,fi) If IsArray(fi) Then Dim sni sni = FindShareNameIndex(fi) TestFieldsInfo = "" For j = 0 To UBound(res,2) TestFieldsInfo = TestFieldsInfo & res(sni,j) & ";" Next Else TestFieldsInfo = fi End If End Function
UpdateValues Method
Updates values in the current Table object.
Syntax
UpdateValues(MatchColumns, MatchValues, SetColumns, SetValues)
Name | Description |
---|---|
MatchColumns |
Array of matching column names to update in the current table. |
MatchValues |
Array of matching column values to update in the current table. |
SetColumns |
Array of column names to set in the current table. |
SetValues |
Array of column values to set in the current table. |
Remarks
The UpdateValues method executes an SQL query with the specified parameters. For example, the following VBScript statement:
Vault.Table("Employees").UpdateValues(Array("FirstName","LastName"), Array("John","Smith"), Array(“Role”, “Department”), Array(“Manager”, “Engineering”))
translates into the following SQL query:
UPDATE Employees SET Role='Manager' AND Department='Engineering' WHERE FirstName='John', LastName='Smith'
UpdateValuesEx Method
Updates values in the current Table object.
Syntax
UpdateValuesEx(Where As String, Parameters, SetColumns, SetValues)
Name | Description |
---|---|
Where |
Condition for matching column values to update in the current table. |
Parameters |
String or array of strings of values to be used in a parameterized query. The array should contain a value for each instance of the ? character in the SQL query. |
SetColumns |
Array of column names to set in the table. |
SetValues |
Array of column values to set in the table. |
Remarks
The UpdateValuesEx method is functionally equivalent to UpdateValues. However, the UpdateValuesEx method supports parameters in the same order as a standard SQL query. This may be more convenient to use than UpdateValues if you are already familiar with the SQL language.