You are here: Surpac Concepts > Macros > SCL > Database Commands > SclOpenDatabase
GEOVIA Surpac

SclOpenDatabase

Overview

This command opens a database and assigns the database handle to a variable passed as an argument to the command.

Synopsis

SclOpenDatabase DatabaseHandle $DatabaseDefinitionFile $DatabaseType

Description

The database whose definition is in the file named in the DatabaseDefinitionFile variable is opened and the database handle is assigned to the DatabaseHandle variable.

It is permissable to have one of each type of database listed below opened at any time.

Arguments

  • DatabaseHandle
  • Passed by reference. If the database is successfully opened the database handle is assigned to this variable.

  • DatabaseDefinitionFile
  • Passed by value. The name of the database definition file in which the database definition is stored. Database definition files with .ddb extensions represent drill hole databases while the extension .sdb is used to signify survey databases.

  • DatabaseType
  • Passed by value. Optional argument of database type. This must be one of the following:

    • "GeologyDatabase"
    • "SurveyDatabase"
    • "SchedulingDatabase"
    • "SurplanDatabase"

    If no type is given, the definition is assumed to be for a geology database.

Returns

$SCL_TRUE if the database was successfully connected. A TCL error is thrown if an error occurs when opening the database. Reasons for errors opening databases include:

  • A database of the given type is already open.
  • There is an error in the database definition file.
  • The database does not exist. Presence of the database definition file does not imply that the database actually exists.

Examples

if {"[catch {SclOpenDatabase DatabaseHandle "woody.ddb" "GeologyDatabase"}]" != 0} {
  puts "Error opening the woody.ddb database"
} else {
  puts "Database woody.ddb successfully opened"
}

SclCloseDatabase DatabaseHandle
puts "Database woody successfully closed"