declaring a database¶
+|–database |
Define a Sculptor or ODBC database |
SYNTAX
+|–database database_id |
The database and its identifier. The identifier is the name by which it will subsequently be referenced in the program. The database may be declared as +database or –-database. If it is declared as +database, the program connects to the database at startup. If it is declared as -–database, the program does not connect to the database until it is opened with the opendb command at run time. |
||||||||||||||||||||||
source = “source_name” |
In case of a DBT_ODBC database, the source property specifies the name of an ODBC data source. The source name can be specified in one of three ways:
Since Sculptor 6.0.0 It’s now possible to connect to a SQL database in the Sculptor server by adding a “SCULPTOR_SERVER=” clause to the start of the source string in an ODBC database declaration. Example: +database mydb {
type = DBT_ODBC
source = "SCULPTOR_SERVER=srv;DSN=mydsn"
riu_timeout = 3
}
Example of an alternative form of source string: source = "SCULPTOR_SERVER=srv;DRIVER=SQL Server;SERVER=SQLS;DATABASE=master"
The SCULPTOR_SERVER clause must be the first clause in the source string. Do not use {} to enclose the Sculptor server name as this is not supported. Connection to the ODBC driver is made on the server and all network traffic is handled by Sculptor, making it unnecessary to install the ODBC driver on the client. If a database is declared as type DBT_SCULPTOR and has a source string, this is prepended to each database filename before it is opened. Example: +database mydb1 {
type = DBT_SCULPTOR
source = "srv:c:/app/data/"
!file FILE1 "file1"
!file FILE2 "subdir/file2"
}
Both file1 and file2 are opened on srv at run-time. It is of course necesary to ensure that a corresponding path to file1.d and subdir/file2.d exists locally for program compilation purposes. |
||||||||||||||||||||||
type = |
The following types, defined in sculptor.h with prefix DBT_, are valid:
|
||||||||||||||||||||||
flags = option_flags |
The valid option flags, defined in sculptor.h with prefix DBFL_, are:
New in version 6.3.0: See the new features.
|
||||||||||||||||||||||
riu_timeout = integer |
Timeout value in seconds. If a timeout occurs, it triggers the riu trap. If no timeout value is set, or if it is set to zero, SQL Server waits indefinitely for a locked record and does not return a record in use status. The riu_timeout value can be changed at run-time, e.g.: mydb->riu_timeout = 5
|
!file file_id “pathname” [create | read | update] !ofile file_id “pathname” create | read | update |
Each file to be accessed or updated in the database is declared by !ofile or !file. These are standard Sculptor declarations for opening keyed files. The !ofile version declares a file which is initially open; !file declares a file which is initially closed. The name = clause of the openfile command can be used to specify a a SQL database connection string as an alternative to a pathname. In this case, the file declaration can be inside or outside the +|– database structure. See SQL database connection strings. |
!cursor cursor_id |
Declares a cursor. The sql command is used at run time to execute SQL statements and associate a set of records with the cursor. |
RELATED TOPICS |