PreviousDTO Programmer's Guide (9.1 revision 1) Next

DtoDictionary Object

Show this topic in Library frames

An object representing a Pervasive dictionary. This object is deprecated in favor of DtoDatabase Object . DtoDictionary can still be used only if you can specify the path to the dictionary on the Open method.

Properties

Path
Returns the path of the dictionary object.

Collections
DtoTables Collection 
Methods
Open method 
Create method 
Close method 
AddTable method 
DropTable method 
Reload method 
Delete method 
Remarks

All of the operations affecting dictionary files have to be done through this object. The user can open a dictionary, create a dictionary, get table information add a table or drop a table using this object.


Note
If instantiating this object using ASP or if you use the CreateObject method in Visual Basic, the progid of DtoDictionary is "DTO.DtoDictionary.2" for DTO2, or "DTO.DtoDictionary.1" for DTO version 1. See DTO2 for more information on the differences between the two versions.
Example
Dim result as DtoResult 
Dim dictionary as New DtoDictionary 
result = dictionary.Open("c:\pvsw\demodata") 
See Also

DtoTables Collection
DtoTable Object

Methods Detail

Open method

Opens a set of data dictionary files using either a database name or a dictionary path.

Syntax
result = Object.Open(path, [user], [password]) 
Arguments

Object
DtoDictionary object
path
Absolute path to the directory containing dictionary files or name of the named database if local.
You cannot use a named database for this argument if you are connected to a remote server.
user
Optional user name for the DDF set
password
Optional password for the DDF set

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

Note
The path argument may either contain a path to the directory containing the DDF files or it can use a name of the database contained in the local DBNAMES.CFG. See DtoDatabases Collection in order to create and maintain database names.

This operation is used in order to open a set of dictionary files. This set must contain FILE.DDF, INDEX.DDF and FIELD.DDF. It may also contain a number of optional DDF files. Remember to call the Close method to free memory. Once the dictionary set is opened no one else can make changes to it until the Close method is called.

More information on the errors returned by the method can be obtained using the Error property of the DtoSession Object.

Example
Dim dictionary as new DtoDictionary 
Dim result as DtoResult 
result = dictionary.Open("c:\pvsw\demodata") 

Create method

Creates an empty set of data dictionary files.

Syntax
result = Object.Create(path, [user], [password]) 
Arguments

Object
DtoDictionary object
path
absolute path to the directory in which the dictionary files to be created.
username
Optional user name for the DDF set
password
Optional password for the DDF set

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

If the directory contained in path argument does not exist, an attempt will be made to create it. If operation is successful a set containing file.ddf, field.ddf, index.ddf will be created.

Remember to call Close method to free memory. Once the dictionary set is created other clients cannot open it or make changes to it until Close method is called.

More information on the errors returned by the method can be obtained using the Error property. Unlike Open method the path parameter can only contain an absolute path.

Example
Dim Dictionary As New DtoDictionary 
Dim result as DtoResult 
result = Dictionary.Create("C:\TEST", "login", 
"password") 
If NOT result = Dto_Success Then 
  MsgBox "Error"+ Session.Error(result) 
End If 

Close method

Closes a set of data dictionary files. Opened using Open method or created using Create method.

Syntax
result = Object.Close 
Arguments

Object
DtoDictionary object

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

Call this method after the dictionary has been opened using Open method or created using Create method. Error information can be obtained using Error property.

Example
Dim dictionary as new DtoDictionary 
Dim result as DtoResult 
result = dictionary.Open("c:\pvsw\demodata") 
' 
' perform operations here 
' 
result = dictionary.Close 

AddTable method

Adds table information to data dictionary files and creates a data file to match the definition.

Syntax
result = Object.AddTable(table) 
Arguments

Object
DtoDictionary object
table
DtoTable object

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

This method adds the table definition to the ddf files and attempts to create the data file specified in Location property of table. If Location property is left blank then this method will attempt to create a data file named tableName.mkd. If a table with such name already exists a number will be appended to the name and another attempt will be made.

In order for this operation to complete successfully at least one column must be defined.

Example

The following example shows how to create a dictionary object and then add a table to it.

Dim Dictionary As New DtoDictionary 
Dim Table As DtoTable 
Dim Tables As DtoTables 
Dim result As dtoResult 
Dim Columns As DtoColumns 
Dim Indexes As DtoIndexes 
Dim Column As DtoColumn 
Dim Index As DtoIndex 
Dim Segments As DtoSegments 
Dim Segment As DtoSegment 
    result = Dictionary.Create("C:\TEST", "login", 
"password") 
    If NOT result = Dto_Success Then 
       MsgBox "Error"+ Session.Error(result) 
    End If 
' ******* Begin AddTable  ******************* 
    Set Table = New DtoTable 
    Set Column = New DtoColumn 
    With Column 
    .Decimal = 0 
    .Flags = dtoColumnNullable 
    .ISR = "" 
    .Name = "F_Int" 
    .Number = 0 
    .Size = 4 
    .Type = dtoTypeInteger 
    End With 
    Table.Columns.Add Column 
    Set Column = New DtoColumn 
    With Column 
    .Decimal = 4 
    .Flags = dtoColumnNullable + dtoColumnCaseInsensitive 
    .ISR = "" 
    .Name = "F_Str" 
    .Number = 1 
    .Size = 55 
    .Type = dtoTypeLString 
    End With 
    Table.Columns.Add Column 
Set Column = New DtoColumn 
    With Column 
    .Decimal = 4 
    .Flags = dtoColumnCaseInsensitive 
    .ISR = "" 
    .Name = "F_Str_Second" 
    .Number = 2 
    .Size = 100 
    .Type = dtoTypeLString 
    End With 
    Table.Columns.Add Column 
    Set Column = New DtoColumn 
    With Column 
    .Decimal = 10 
    .Flags = dtoColumnDefault 
    .ISR = "" 
    .Name = "F_Float" 
    .Number = 3 
    .Size = 0 
    .Type = dtoTypeBFloat 
    End With 
    Table.Columns.Add Column 
'Add Indexes     
    Set Index = New DtoIndex 
    result = Index.AddSegment("F_Int", 0) 
    Set Segment = New DtoSegment 
    Segment.Number = 0 
    Segment.ColumnName = "F_Int" 
    Segment.Flags = dtoSegmentAscending 
    Index.Segments.Add Segment 
    Index.Name = "FintInd" 
    Index.Number = 0 
    Index.Flags = dtoIndexModifiable 
    Table.Indexes.Add Index 
'Add second Index: 
    Set Index = New DtoIndex 
    Set Segment = New DtoSegment 
    Segment.Number = 0 
    Segment.ColumnName = "F_Str" 
    Segment.Flags = dtoSegmentAscending 
    Index.Segments.Add Segment 
     
    Set Segment = New DtoSegment 
    Segment.Number = 1 
    Segment.ColumnName = "F_Str_Second" 
    Segment.Flags = dtoSegmentAscending 
    Index.Segments.Add Segment 
     
    Index.Name = "FStrTagInd" 
    Index.Number = 1 
    Index.Flags = dtoIndexModifiable 
    Table.Indexes.Add Index 
     
    Table.Overwrite = true 
    Table.Flags = dtoTableTrueNullable 
    Table.Name = "Table3" 
    result = Dictionary.AddTable(Table) 
    If NOT result = Dto_Success Then 
       MsgBox "Error"+ Session.Error(result) 
    End If 

DropTable method

Remove a table from the current dictionary.

Syntax
result = Object.DropTable(tableName, [deleteFile]) 
Arguments

Object
DtoDictionary object
tableName
Name of the table to be dropped
deleteFile
A boolean value indicating whether the underlying data file should be deleted.

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Remarks

Note that the dictionary has to be opened successfully for this operation to succeed.

Example
 result = Dictionary.DropTable("Table3", true) 
    If NOT result = Dto_Success Then 
        MsgBox "Error"+ Session.Error(result) 
    End If 

Reload method

Refreshes a dictionary object.

Syntax
result = Object.Reload 
Arguments

Object
DtoDictionary object

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.

Delete method

Deletes dictionary object and the corresponding DDF files.

Syntax
result = Object.Delete 
Arguments

Object
DtoDictionary object

Return Values

result
DtoResult long value indicating the result of the method call. Use the Error property of the DtoSession Object to obtain a description for the result.


Chapter contents
Publication contents

Prev topic: DtoDSN Object
Next topic: DtoTables Collection