This document describes how I tested the ODBC module of ScriptBasic and of course evaluates the results of testing. In the test definition I defined what and how to test. The testing environment section describes the hardware and software environment in wich the tests were carried out. In the test program section you can find the test program I wrote. Of course you can download the basic program and test your own configuration with it. In the test results section the all test results can be found. The last section contains the conclusion on the usability of ScriptBasic module ODBC.
The ODBC module of ScriptBasic implements only limited functionality of ODBC. Testing an ODBC connection does not require testing all capabilities of the database system behind the ODBC layer. The following should be tested:
The following should be tested:
Correctness (validity) and intelligibility of evrery declaration and example should be examined.
All tests were carried out on a single PC running Windows XP Professional (NT 5.1 build 2600).
Other software used for testing module ODBC were:
The test program was designed to produce a human readable output. If a function of module ODBC is used in a line of the test program that particular line is printed out before executing the command so that the last command could be read in case of an unexpected error. If the error can be handled inside the SriptBasic environment, an error code is printed out too, and execution continues on the next line. (In the case of two configured ODBC resources one can pass the tests while the other can raise errors that are handled so they do not disturb the testing of the correctly working resource.)
The test program can be found here for online reading (XHTML) or for downloading (odbctest.bas). Before running the program read further, please. (The output of the test program run in my test environment can be found here.)
If you intend to run the test program in your ScriptBasic + ODBC environment, you have to configure the parameters of the ODBC resources in the "odbctest config" section of test program and in scriba.conf. After editing the ScriptBasic configuration you have to translate it into binary form as described in the "ScriptBasic Users Guide". Here is the odbc section of my config:
odbc (
connections (
odbctest ( ; the name of the connection
dsn "odbctest" ; data source name
user "odbctest" ; user for the connection
password "pwd" ; password for the connection
)
odbctest2 ( ; the name of the connection
dsn "odbctest2" ; data source name
user "odbctest" ; user for the connection
password "pwd" ; password for the connection
)
badodbctest ( ; the name of the connection
dsn "badodbctest" ; data source name
user "odbctest" ; user for the connection
password "pwd" ; password for the connection
)
badodbctest2 ( ; the name of the connection
dsn_with_error "badodbctest" ; data source name
user_with_error "odbctest" ; user for the connection
password_with_error "pwd" ; password for the connection
)
)
)
The third and fourth connections (badodbctest and badodbctest2) are for testing errors in the config file.
In the "odbctest config" section of the test program all parameters of an ODBC connection (data source name, user name, password) are stored in arrays so you can configure and test multiple ODBC connections simultaneously. For proper operation you have to define the exact number of ODBC resources you have configured and intend to test.
There are sections in the test code that are commented out because they raise errors that cannot be handled inside the ScriptBasic environment (the Operating System terminates scriba.exe as ultimate error handling)
For further details look at the test program source, please. I hope it will not be hard to read and understand. Some sections (e.g. the subrutine that prints out the results of an arbitrary SQL select query automatically determining column names) might help understanding how the services provided by module ODBC can be used. The code of the test program can be reused and modified under the conditions of the BSD style license that can be found in the source file (odbctest.bas).
The documentation of module ODBC was clear and useful in conjunction with "ScriptBasic Users Guide". The only error I found in the documentation was the way ODBC::Connect and ODBC::RealConnect were defined. In the documentation the following lines can be found:
DB = ODBC::Connect connection_name
DB = ODBC::RealConnect DSN,User,Password
These lines raise a syntax error if inserted into a basic program. To avoid the error parentheses should be used the following way:
DB = ODBC::Connect(connection_name)
DB = ODBC::RealConnect(DSN,User,Password)
I must state that if the ODBC resources are configured well and you do not make serious mistakes in your basic code, module ODBC works fine. It works as it is described in the documentation. If you make errors in the configuration or in your program code, you may find that scriba.exe is terminated by the operating system sometimes. It sounds bad, but it only happens when continuing the basic program would not be possible even if the error was handled by ScriptBasic. Of course the error code would help you debugging your code and configuration. Such cases are commented out in the test program, you can have a look at them if you are interested. Let's see the buggy cases:
The latter two are more important as they appear in the documentation as errors handled by the module.
Using ODBC:RealConnect no problem occures, so ODBC:RealConnect can be used to test your ODBC connection. If ODBC:RealConnect works fine and ODBC:connect do not work, there may be an error in your scriba configuration (You might have forgotten to compile it after modification, or it is erroneous.)
I state again, these errors only occur if you have a bad configuration file, or if you have mistyped the name of an ODBC connection that is properly configured in your ScriptBasic configuration file. Such things can annoy the programmer during develepoment and deployment, but they never occur after correcting the scriba configuration or mistyped connection names in program code.
The output of the test program run in my test environment can be found here.
The ODBC module of ScriptBasic works fine despite the bugs described in the test results section of this document. The bugs only occur at development and deployment time, so running a program (that does not contain serious errors) in a well configured ScriptBasic + ODBC environment should be safe.
| Gábor Pohl (pg@mail.klassic.hu) |
|