![]() |
![]() |
![]() |
![]() |
3 Database-Specific Usage
This chapter details database-specific usage of the Database Kit. The sections include:
For information on current release versions of databases and their compatibility with the Database Kit and AVS/Express see the book Installing AVS/Express or our web site at http://www.avs.com/. Any critical information about database changes will be found in the release notes.
This section provides database-specific usage notes for developing and using Database Kit applications that access Oracle's standard databases, Spatial Data Option, and the Spatial Data Cartridge.
- Local and Remote Oracle Connects
- Supplying Connection Information
- Mapping Oracle Datatypes to Database Kit Datatypes
- Fetch-Processing Buffer Contents
- Building the Oracle Database-Specific Module
Oracle connects are either local or remote. In either case, a SQL*Net component is involved. By default, your Database Kit is linked with the SQL*Net protocols noted in Section 1.7 Database Kit Requirements of the Installing AVS/Express manual.
When connecting to a database, you must supply either a connect string or the elements from which to construct a connect string. The format of a connect string is database specific. In addition, connect strings can vary depending on how the database driver has been installed, what networking component(s) it uses, where the associated server resides, and so forth.
Generally, you should see your database administrator to obtain a valid connect string. However, this section provides some general information on Oracle connect string format. For more information, see your database documentation.
An Oracle connect string always requires a user name. In addition, it may require a user password and/or the name or alias of a database, depending on how the user's database administrator has configured the server and set up the user's account. For example, the user account may not require a password, or the user may be allowed to connect only to one database.
A typical Oracle connect string has one of the following formats:
The components have the following meanings:
A user ID (user name); for example, SCOTT.
The user's password; for example, TIGER.
A database name, specified as follows:
- A SQL*Net connect string or alias. Note that a SQL*Net connect string is not the same as a Database Kit connect string. In Oracle usage, the term "connect string" is used in a SQL*Net context to indicate the database to which to connect. An alias is a short name for a SQL*Net connect string.
- A SQL*Net connect descriptor or service name. Note that a SQL*Net connect descriptor is not the same as a Database Kit connect descriptor. In Oracle usage, the term "connect descriptor" is used in a SQL*Net context to indicate the database to which to connect. A service name is a short name for a SQL*Net connect descriptor; it is defined in a file called tnsnames.ora that is set up by your database administrator.
Here are some examples of typical connect strings:
If SQL*Plus is available on your machine, you can use it to verify that a connect string is valid. To do this, try to connect to the tool using the desired connect string. If the connect is successful, the connect string is valid and can be used with AVS/Express. If SQL*Plus is not available on your machine, you should locate a machine on which it is installed and test the validity of the connect string there.
In some circumstances, a connect string will work with SQL*Plus but not with the Database Kit. This may occur because different network drivers are linked to the Database Kit than to the SQL*Plus; there may also be other site-specific reasons for this problem. Ask your database administrator for assistance.
In order to resolve this problem, your database administrator may need to know how the underlying layers of the Database Kit handle a connect attempt. The Database Kit uses an Oracle Call Interface (OCI) call named olog to connect to a database. Here is the format of the olog call:
Recall that you can supply either a connect string or the elements from which to construct a connect string. In either case, the connect string is passed to the Oracle server as the uid parameter of the olog call. This field contains the connect string in whatever format it is supplied. (See the previous section or your database documentation for more information on connect string formats.)
Note: The Database Kit does not use the pswd parameter of the olog call; this field is null.
For more information on OCI and the olog call, see your Oracle documentation.
Oracle maintains data in the data dictionary as a set of internal datatypes. The following table lists these datatypes and their specifications, and notes the C-language datatype to which the Database Kit maps them. (The list of internal datatypes and specifications are derived from the Oracle documentation.)
Note: As of version 7.1x, Oracle returns a SCALE of 0 for all columns that result from the use of UNION, UNION ALL and INTERSECT operators. The database-independent layer relies completely on the "describe" feature of the Oracle Call-level Interface (OCI) when deciding on datatypes and will therefore map them to a fixed type. This will generate a runtime Oracle NUMERIC OVERFLOW error, which in turn will generate the Database Kit error DB ERROR: Recoverable database error. To work around the problem, use the use_floating_type_only parameter to specify that all data is mapped to a floating type (see Mapping Data to Supported Database Kit Datatypes on page 1-22).
Oracle stores all columns defined for a table as one of these internal datatypes, regardless of the exact mode of creation. For example, Oracle supports the ANSI datatypes of float, int, and so forth in the CREATE TABLE statement, but stores both the float and int data as the "number" internal datatype. When the Database Kit queries the database server about a datatype, the original, Oracle user-specified datatype - for example, "float" - is lost and the appropriate Oracle internal type - "number" - is returned along with the scale and precision as maintained internally by Oracle. The Database Kit supports only C-language datatypes, and when a nonzero scale is indicated, it stores the "float" data as C-language float or double float data.
For Oracle databases, the fetchret, fetchind, and fetchsize buffers are copied directly from the arrays used by the OCI and are not modified by the Database Kit.
The Oracle database-specific module is used to access both the standard and the Spatial Data Option databases. The OCI was used to build the Oracle database-specific module. (The version of the OCI varies by platform.) The following C-language calls are used:
AVS/Express supports the Open Database Connectivity (ODBC) interface. This section describes issues associated with developing and using AVS/Express applications that use the ODBC interface to access databases on a PC.
Note: The ODBC interface is a Windows-only interface; it is not supported on UNIX platforms.
AVS/Express uses the ODBC product for connecting to an ODBC compliant database server. The Database Kit includes object code from ODBC libraries that are normally found in the directory C:\MSDEV\LIB. The ODBC library is called odbc32.lib.
The ODBC setup tool for Windows NT is located in the Control Panel. This setup tool maintains the ODBC data sources and drivers for connecting to a database server. This tool helps you add drivers, determine what drivers are already installed on your PC, and set up the correct connection information to the database of choice. When using the setup tool, you specify the information that is required when connecting to the database via AVS/Express; for example, the elements to establish a physical connection to the database server.
The information that follows is general connection information. The required information is database specific, so you should see your database administrator or your database documentation to obtain valid connection information.
The table below defines the connect elements and their meaning:
ODBC maintains data in the data library as a set of internal datatypes. The following table lists these datatypes and maps them to their equivalent C-language datatype.
Note: ODBC stores all columns defined for a table as one of these internal datatypes, regardless of the exact mode of creation. The Database Kit supports only C-language datatypes, and when a non-zero scale is indicated, it stores the "float" data using C-language float or double float format.
![]() |
![]() |
![]() |
![]() |
![]() |
Copyright © 2001 Advanced Visual Systems
Inc.
All rights reserved.