HP SQL/MX ODBC/MX client drivers User Guide
Below you will find brief information for ODBC/MX client drivers SQL/MX. This guide provides information on how to install, configure and use the ODBC/MX client drivers. These drivers allow applications developed for Open Database Connectivity (ODBC) to access data from an SQL/MX database on a NonStop system. The drivers implement the ODBC 3.5 set of APIs.
advertisement
Assistant Bot
Need help? Our chatbot has already read the manual and is ready to assist you. Feel free to ask any questions about the device, but providing details will make the conversation more productive.
HP NonStop ODBC/MX Client Drivers User
Guide for SQL/MX Release 3.2.1
HP Part Number: 734873-002
Published: November 2013
Edition: J06.16 and subsequent J-series RVUs; H06.27 and subsequent H-series RVUs
© Copyright 2013 Hewlett-Packard Development Company, L.P.
Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial
Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license.
The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.
Export of the information contained in this publication may require authorization from the U.S. Department of Commerce.
Microsoft, Windows, and Windows NT are U.S. registered trademarks of Microsoft Corporation.
Intel, Pentium, and Celeron are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
Java is a registered trademark of Oracle and/or its affiliates.
Motif, OSF/1, UNIX, X/Open, and the "X" device are registered trademarks, and IT DialTone and The Open Group are trademarks of The Open
Group in the U.S. and other countries.
Open Software Foundation, OSF, the OSF logo, OSF/1, OSF/Motif, and Motif are trademarks of the Open Software Foundation, Inc.
OSF MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THE OSF MATERIAL PROVIDED HEREIN, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
OSF shall not be liable for errors contained herein or for incidental consequential damages in connection with the furnishing, performance, or use of this material.
© 1990, 1991, 1992, 1993 Open Software Foundation, Inc. The OSF documentation and the OSF software to which it relates are derived in part from materials supplied by the following:
© 1987, 1988, 1989 Carnegie-Mellon University. © 1989, 1990, 1991 Digital Equipment Corporation. © 1985, 1988, 1989, 1990 Encore
Computer Corporation. © 1988 Free Software Foundation, Inc. © 1987, 1988, 1989, 1990, 1991 Hewlett-Packard Company. © 1985, 1987,
1988, 1989, 1990, 1991, 1992 International Business Machines Corporation. © 1988, 1989 Massachusetts Institute of Technology. © 1988,
1989, 1990 Mentat Inc. © 1988 Microsoft Corporation. © 1987, 1988, 1989, 1990, 1991, 1992 SecureWare, Inc. © 1990, 1991 Siemens
Nixdorf Informationssysteme AG. © 1986, 1989, 1996, 1997 Sun Microsystems, Inc. © 1989, 1990, 1991 Transarc Corporation.
OSF software and documentation are based in part on the Fourth Berkeley Software Distribution under license from The Regents of the University of California. OSF acknowledges the following individuals and institutions for their role in its development: Kenneth C.R.C. Arnold, Gregory S.
Couch, Conrad C. Huang, Ed James, Symmetric Computer Systems, Robert Elz. © 1980, 1981, 1982, 1983, 1985, 1986, 1987, 1988, 1989
Regents of the University of California.
Contents
4 Compatibility and considerations...............................................................37
Contents 3
A Sample ODBC application .......................................................................53
4 Contents
About this document
This manual describes how to install, configure and use the ODBC/MX client drivers. These drivers allow HP-UX, Linux32, Linux64, OSS and Windows applications developed for Open Database
Connectivity (ODBC) to access data from an SQL/MX database on a NonStop system.
Intended audience
This manual is intended for the following audience:
•
ODBC application programmers who develop applications to access data from an SQL/MX database
•
Administrators installing and configuring the driver on the HP-UX, Linux, OSS, and Windows platforms
Document organization
Chapter Name
Chapter 2: Installing the drivers
Chapter 3: Configuring data sources
Chapter 4: Compatibility and considerations
Appendix A: Sample ODBC application
Description
Provides an overview of the ODBC/MX client drivers.
Describes procedures to install the ODBC/MX client drivers.
Describes steps to configure the client data sources.
Lists the compatibility for the drivers.
Lists the error codes and messages.
Provides a sample ODBC application.
New and changed information in this edition
Changes to the 734873–002 manual:
•
Added information about AutoCommit in
“Managing transactions” (page 34)
.
•
Added information about Linux 64 bit driver across the manual.
This manual combines the following manuals:
•
Open System Services ODBC/MX Client Driver for SQL/MX Release 3.2.1
•
Linux ODBC/MX Client Driver for SQL/MX Release 3.2.1
•
ODBC/MX Driver for Windows Manual for SQL/MX Release 3.2.1
This manual also contains added information on configuring secure ODBC connection for NonStop
SSL, HP-UX driver, and Unicode support in Windows ODBC/MX client driver.
Notation conventions
General syntax notation
This list summarizes the notation conventions for syntax presentation in this manual.
UPPERCASE LETTERS
Uppercase letters indicate keywords and reserved words. Type these items exactly as shown.
Items not enclosed in brackets are required. For example:
SELECT
Intended audience 5
6
Italic Letters
Italic letters, regardless of font, indicate variable items that you supply. Items not enclosed in brackets are required. For example:
file-name
Computer Type
Computer type letters within text indicate case-sensitive keywords and reserved words. Type these items exactly as shown. Items not enclosed in brackets are required. For example: myfile.sh
Bold Text
Bold text in an example indicates user input typed at the terminal. For example:
ENTER RUN CODE
?123
CODE RECEIVED: 123.00
The user must press the Return key after typing the input.
[ ] Brackets
Brackets enclose optional syntax items. For example:
DATETIME [start-field TO] end-field
A group of items enclosed in brackets is a list from which you can select one item or none. The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. For example:
DROP schema [CASCADE]
[RESTRICT]
DROP schema [ CASCADE | RESTRICT ]
{ } Braces
Braces enclose required syntax items. For example:
FROM { grantee[, grantee]...}
A group of items enclosed in braces is a list from which you are required to select one item.
The items in the list can be arranged either vertically, with aligned braces on each side of the list, or horizontally, enclosed in a pair of braces and separated by vertical lines. For example:
INTERVAL { start-field TO end-field }
{ single-field }
INTERVAL { start-field TO end-field | single-field }
| Vertical Line
A vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces.
For example:
{expression | NULL}
… Ellipsis
An ellipsis immediately following a pair of brackets or braces indicates that you can repeat the enclosed sequence of syntax items any number of times. For example:
ATTRIBUTE[S] attribute [, attribute]...
{, sql-expression}...
An ellipsis immediately following a single syntax item indicates that you can repeat that syntax item any number of times. For example:
expression-n…
Punctuation
Parentheses, commas, semicolons, and other symbols not previously described must be typed as shown. For example:
DAY (datetime-expression)
@script-file
Quotation marks around a symbol such as a bracket or brace indicate the symbol is a required character that you must type as shown. For example:
"{" module-name [, module-name]... "}"
Item Spacing
Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. For example:
DAY (datetime-expression)
DAY(datetime-expression)
If there is no space between two items, spaces are not permitted. In this example, no spaces are permitted between the period and any other items:
myfile.sh
Line Spacing
If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. This spacing distinguishes items in a continuation line from items in a vertical list of selections. For example:
match-value [NOT] LIKE pattern
[ESCAPE esc-char-expression]
Related Documentation
This manual is part of the HP NonStop SQL/MX library of manuals.
NonStop SQL/MX customer library
The manuals in the SQL/MX customer library are listed here for your convenience.
•
Introductory guides
SQL/MX Comparison Guide for
SQL/MP Users
Describes differences between NonStop SQL/MP and NonStop SQL/MX databases.
SQL/MX Quick Start Guide
Describes basic techniques for using SQL in the SQL/MX conversational interface
(MXCI). Includes information about installing the sample database.
Related Documentation 7
8
•
Installation guides
SQL/MX Installation and
Upgrade Guide
Describes how to plan for install and upgrade an SQL/MX database.
SQL/MX Management Manual
Describes how to manage an SQL/MX database.
NSM/web Installation Guide
Describes how to install NSM/web and troubleshoot NSM/web installations.
•
Reference manuals
SQL/MX Reference Manual
SQL/MX Messages Manual
SQL/MX Glossary
Describes the syntax of SQL/MX statements, MXCI commands, functions, and other SQL/MX language elements.
Describes SQL/MX messages.
Defines SQL/MX terminology.
•
Connectivity manuals
SQL/MX Connectivity Service
Manual
SQL/MX Connectivity Service
Administrative Command
Reference
SQL/MX Remote
Conversational Interface
(RMXCI) Guide
HP NonStop JDBC Type 4
Driver 3.0 Programmer's
Reference
ODBC/MX Client Drivers User
Guide
This manual is an installation guide and describes how to install and manage
SQL/MX Connectivity Service (MXCS), which enables ODBC and other connectivity APIs to use NonStop SQL/MX.
Describes the SQL/MX Administrative Command Library (MACL) available with the SQL/MX conversational interface (MXCI).
Describes how to use SQL/MX Remote Conversational Interface to run the RMXCI commands, and SQL statements interactively or from script files.
Describes the NonStop JDBC Type 4 Driver functionality, which allows Java programmers to remotely develop applications deployed on client workstations to access NonStop SQL/MX databases.
Describes how to install and configure the ODBC/MX client drivers. These products enable applications developed for the Open Database Connectivity
(ODBC) application programming interface to access data from an SQL/MX database on a NonStop system.
•
Migration guides
SQL/MX Database and
Application Migration Guide
NonStop NS-Series Database
Migration Guide
Describes how to migrate databases and applications to NonStop SQL/MX, and how to manage different versions of NonStop SQL/MX.
Describes how to migrate NonStop SQL/MX, NonStop SQL/MP, Enscribe databases and applications to HP Integrity NonStop NS-series systems.
•
Data management guides
SQL/MX Data Mining Guide
SQL/MX Report Writer Guide
DataLoader/MX Reference
Manual
Describes the SQL/MX data structures and operations for data mining.
Describes how to produce formatted reports using data from an SQL/MX database.
Describes the features and functions of the DataLoader/MX product, a tool to load SQL/MX databases.
•
Application development guides
SQL/MX Programming Manual for C and COBOL
Describes how to embed SQL/MX statements in ANSI C and COBOL programs.
SQL/MX Query Guide
SQL/MX Queuing and
Publish/Subscribe Services
SQL/MX Guide to Stored
Procedures in Java
Describes how to understand query execution plans and write optimal queries for an SQL/MX database.
Describes how NonStop SQL/MX integrates transactional queuing and publish/subscribe services into its database infrastructure.
Describes how to use stored procedures that are written in Java within NonStop
SQL/MX.
•
Online help
Reference Help
Messages Help
Glossary Help
NSM/web Help
Visual Query Planner Help
SQL/MX Database Manager
Help
Overview and reference entries from the SQL/MX Reference Manual.
Individual messages grouped by source from the SQL/MX Messages Manual.
Terms and definitions from the SQL/MX Glossary.
Context-sensitive help topics that describe how to use the NSM/web management tool.
Context-sensitive help topics that describe how to use the Visual Query Planner graphical user interface.
Contents and reference entries from the SQL/MX Database Manager User
Guide.
Publishing history
Part Number
734873-001
734873-002
Product Version Publication Date
ODBC/MX Client Drivers User
Guide for SQL/MX Release
3.2.1
August 2013
ODBC/MX Client Drivers User
Guide for SQL/MX Release
3.2.1
November 2013
HP encourages your comments
HP encourages your comments concerning this document. We are committed to providing documentation that meets your needs. Send any errors found, suggestions for improvement, or compliments to: [email protected]
Include the document title, part number, and any comment, error found, or suggestion for improvement you have concerning this document.
Publishing history 9
1 Overview
The following ODBC/MX client drivers enable ODBC applications running on various platforms, to access a NonStop SQL/MX database:
•
Linux 32–bit and 64–bit drivers
•
HP-UX 64–bit driver
•
Windows 32–bit and 64–bit drivers for ANSI and Unicode applications
•
OSS 32–bit and 64–bit libraries
The HP-UX, Linux, OSS, Windows ANSI and Unicode ODBC/MX client drivers are collectively referred as drivers. In this manual the HP-UX, Linux, and OSS drivers are collectively referred as
Unix drivers.
The drivers implement the ODBC 3.5 set of APIs. The ODBC client applications (applications) send the requests to access data from an SQL/MX database through these drivers.
This chapter describes the following:
•
•
•
•
•
•
•
Object naming and mapping (page 14)
•
Unsupported ODBC APIs (page 14)
•
Unsupported ODBC data types (page 15)
•
Considerations and limitations (page 15)
Architecture
The applications interact with the drivers to access an SQL/MX database.
The Unix drivers are thread-safe, and you can write multi-threaded C/C++ applications, which use the POSIX thread library.
illustrates the architecture, which comprise client and server components.
10 Overview
Figure 1 Architecture
Application unixODBC DM HP SQL/MX DM
HP Linux/HP UX ODBC/MX Driver
ODBC/MX Client
(Linux or HP-UX System)
Application
OSS ODBC/MX Client Driver
ODBC/MX Server (MXCS)
Configuration Server
Association
Server
ODBC
Server
Application
Microsoft ODBC DM
HP ANSI/
Unicode
ODBC/MX Driver
Data sources A and B
DB
Nonstop System
ODBC/MX Client
(Windows System)
A - TDM_Default_Data Source
B - Data Source B
DB - SQL/MX Database
The application calls the SQLConnect() ODBC API to open a connection to a data source, which represents NonStop SQL on the host. The NonStop SQL/MX Connectivity Service (MXCS) provides support for remote connections to the SQL/MX database. For example, support for remote connections from ODBC and JDBC applications. The drivers forward the request to MXCS, which authenticates the connection parameters. After successful authentication, MXCS assigns an ODBC server instance to the application. MXCS matches the client data source name with server data source name. If the client data source name matches the server data source name, MXCS attempts a connection. MXCS connects to the data source based on the following conditions:
•
The data source must be configured and started.
•
If the data source is not configured on the server, then MXCS forwards the connect request to the default data source, TDM_Default_DataSource.
After the connection is established, MXCS forwards the application requests to the SQL/MX database, and routes the responses from the database to the driver.
The communication between the driver and MXCS is over TCP/IP sockets in the client-server parlance. Configure the IP address and the port number for the HP-UX and Linux drivers in the
Architecture 11
MXODSN file, and for the OSS driver in the ODBCDSN file. Use the Microsoft ODBC Data Source
Administrator to configure the parameters for the Windows driver.
Client components
The common client components are the ODBC applications, which are user-written or third-party products that use the ODBC APIs, and the driver for the application platform. Install the following client components for HP-UX, Linux, and Windows platforms:
HP-UX
• unixODBC driver manager (only required for standalone driver, libmxodbc_ia64_drvr.sl
), which is the open source driver manager implementation that you can download from the unixODBC website http://www.unixODBC.org
.
•
SQL/MX driver manager, which is the driver manager implementation from HP and includes a set of APIs, which internally makes multiple ODBC API calls.
Linux 32
• unixODBC driver manager (only required for standalone driver, libmxodbc_l_drvr.so), which is the open source driver manager implementation that you can download from the unixODBC website http://www.unixODBC.org
.
•
SQL/MX driver manager, which is the driver manager implementation from HP and includes a set of APIs, which internally makes multiple ODBC API calls.
Linux 64
• unixODBC driver manager (only required for standalone driver, libmxodbc64_l_drvr.so
), which is the open source driver manager implementation that you can download from the unixODBC website http://www.unixODBC.org
.
•
SQL/MX driver manager, which is the driver manager implementation from HP and includes a set of APIs, which internally makes multiple ODBC API calls.
Windows
•
Microsoft ODBC Driver Manager version 3.5.1 or later, which manages ODBC API requests to ODBC drivers.
•
Microsoft ODBC Data Source Administrator.
Server components
The following server components are required on the NonStop system:
•
SQL/MX database release 3.2.1
•
MXCS
Driver managers
The HP-UX or Linux applications can use either the unixODBC driver manger versions 2.2.14, or
2.3.1 and later, or the SQL/MX driver manager. When compiling, the applications can directly link with the unixODBC library or can use connectors to communicate with the driver manager.
The driver manager uses the information provided by the applications and routes the ODBC API calls to the driver.
For more information about unixODBC driver manager, see the unixODBC website http:// www.unixODBC.org
.
The Windows applications use the Microsoft ODBC Driver Manager version 3.5.1 or later.
12 Overview
Data sources
Data sources are logical groupings of connections to the SQL/MX database. There are two types of data sources.
•
Client data source, commonly known as Data Source Name (DSN). The DSN is configured on the client workstation.
•
Server data source, which you must define and start on the NonStop system.
The driver uses the client data source configuration to route the ODBC API requests to MXCS.
For more information about data sources, see the HP NonStop SQL/MX Connectivity Service
Manual for SQL/MX Release 3.x.
Client data source configuration
The client data sources are configured on the client workstation.
HP-UX, Linux32 and Linux 64
•
Configure the client data sources in the MXODSN file when the driver uses the SQL/MX driver manager.
•
Configure the client data sources in the odbc.ini and odbcinst.ini files when the driver uses the unixODBC driver manager.
OSS
You must configure the data source in the ODBCDSN file.
Windows
You must configure the client data sources with Microsoft ODBC Data Source Administrator.
The driver accesses the configuration details when it sends a connect request to MXCS. If the data source is not configured on the server, MXCS connects the application to the default data source,
TDM_Default_DataSource
.
Server data source configuration
The server data sources are configured on a NonStop server. For more information about configuring and managing server data sources, see the HP NonStop SQL/MX Connectivity Service Manual
for SQL/MX Release 3.x.
Default data source
TDM_Default_DataSource is the pre-configured default server data source. You can stop and start TDM_Default_DataSource with any one of the following, but you cannot delete it:
•
NSM/web
•
SQL/MX Administrative Command Library (MACL, mode mxcs invoked from mxci)
•
SQL/MX Remote Conversational Interface (RMXCI)
•
SQL/MX Database Manager (available from SQL/MX Release 3.2 onwards)
MXCS establishes a connection with TDM_Default_DataSource when there is a mismatch in the client and server data source names.
For more information about MACL, see the SQL/MX Connectivity Service Administrative Command
Reference .
Data sources 13
Tracing
HP-UX, Linux 32 and Linux 64
The trace information is captured in a log file. You can enable or disable tracing and specify the trace file name in MXODSN file. When using the unixODBC driver manager, you can enable the driver tracing by setting the following environment variables:
•
HPODBC_TRACE_LEVEL. For trace values, see
“MXODSN and ODBCDSN file formats”
.
•
HPODBC_TRACEFILE_NAME to set the trace file name. The PID and current time are appended to this name to form the final trace file name.
•
HPODBC_TRACEFILE_SIZE to set the maximum trace file size. The default file size is 1 GB.
OSS
The trace information is captured in an OSS log file. You can enable or disable tracing and specify the trace file name in ODBCDSN file.
Windows
You can trace the entry and exit calls from the Microsoft driver manager to the driver, contents of the buffers (except password buffers), and activity between the driver and transport layer.
To get the tracing help, click the Help button in the Microsoft ODBC Data Source Administrator panel.
NOTE: For information about MXCS tracing, see SQL/MX Connectivity Service Administrative
Command Reference manual.
Object naming and mapping
The drivers can access SQL/MX database objects and SQL/MP objects that have an alias.
ANSI name type
Only ANSI name types are supported for SQL/MX database objects. You can configure the default catalog and schema names to qualify table names in the queries. The name format is: catalog.schema.object-name
ANSI names have a maximum of 128 characters for each part of the name (not including the dots).
ANSI names for SQL/MX objects
ANSI names for SQL/MX database objects are registered in the metadata in SQL/MX tables.
ANSI alias names for SQL/MP objects
Only ANSI name types are supported for SQL/MP database objects. Alias names are ANSI standard names that map to physical Guardian names for existing SQL/MP objects.
To add ANSI alias names for SQL/MP tables, use the command CREATE SQLMP ALIAS, which stores the alias name in the SQL/MX catalog. For more information about CREATE SQLMP ALIAS command, see the SQL/MX 3.x Reference Manual.
Unsupported ODBC APIs
The drivers are ODBC 3.5 compliant.
lists the unsupported ODBC APIs.
14 Overview
Table 1 Unsupported ODBC APIs
Category
Installer – Data Sources
Installer – Drivers
Installer – Driver Manager
Installer – Installer Errors
Installer – Profile Strings
Installer – Translator
Installer – Config Mode
Bulk operations
Scroll operations
Unsupported APIs
•
SQLManageDataSources
•
SQLRemoveDefaultDataSource
•
SQLConfigDataSource
•
SQLCreateDataSource
•
SQLValidDSN
•
SQLRemoveDSNFromIni
•
SQLWriteDSNToIni
•
SQLConfigDriver
•
SQLRemoveDriver
•
SQLInstallDriver
•
SQLInstallDriverEx
•
SQLValidDSN
•
SQLGetInstalledDrivers
•
SQLRemoveDriverManager
•
SQLInstallDriverManager
•
SQLInstallerError
•
SQLPostInstallerError
•
SQLWritePrivateProfileString
•
SQLGetPrivateProfileString
•
SQLInstallTranslator
•
SQLInstallTranslatorEx
•
SQLRemoveTranslator
•
SQLGetTranslator
•
SQLSetConfigMode
•
SQLGetConfigMode
SQLBulkOperations
•
SQLFetchScroll supported only for SQL_FETCH_NEXT attribute
•
SQLSetScrollOption
Unsupported ODBC data types
The drivers do not support the BINARY, VARBINARY and LONG VARBINARY data types.
Considerations and limitations
The Unix drivers do not support the following:
•
Module File Caching (MFC)
•
GUI for configuring the driver manager
Unsupported ODBC data types 15
The following are the considerations and limitations for the Windows Unicode driver:
•
You cannot execute DDL statements with character set qualifiers _UCS2 or N.
•
Prefix _UCS2 or N to the string literal for the following columns to execute DML statements:
◦
CHAR CHARACTER SET UCS2 column
◦
NCHAR column — the default NATIONAL character set is UCS2
◦
VARCHAR CHARACTER SET UCS2 column
◦
NCHAR VARYING column — the default NATIONAL character set is UCS2
For example, insert into CAT.SCH.TAB (unicodechar_col) values (_UCS2'abcd');
•
The driver does not support KANJI and KSC5601 as NATIONAL character set. Prefix _kanji or _ksc5601 to the string literal for NCHAR column if SQL/MX is installed with KANJI and
KSC5601 as NATIONAL character set.
•
SQL statements and SQLBindParameter values must be in UTF-16 format.
•
The driver considers C variable of type SQL_C_DEFAULT as SQL_C_CHAR instead of
SQL_C_WCHAR to match with the SQL data type of the column or parameter.
•
Consider the following byte length for IN or OUT WCHAR parameter buffer length:
◦
Number of characters * 2 for double byte Unicode characters
◦
Number of characters * 4 for supplementary Unicode characters
•
When the trace is on, the Unicode characters in the SQL statements may not get displayed properly in the log file.
16 Overview
2 Installing the drivers
The hardware and software requirements for the drivers are described in the softdoc or README file delivered with the products, either through the product CD or through the Scout website for
NonStop servers in the HP NonStop eServices portal ( https://onepoint.nonstop.compaq.com/ ).
This chapter describes the following:
•
•
•
Installation requirements
HP-UX
A standard HP–UXia64 installation is required for the driver. If you want the applications to use the unixODBC driver manager, then download and install unixODBC driver manager release 2.2.14, or 2.3.1 and later. For installing unixODBC, see the unixODBC website http:// www.unixODBC.org
.
Linux 32
The Linux driver is LSB 4.1 compliant and is tested on RHEL 5.1, 6.0 and ubuntu 11.4. A standard Linux installation is required for the driver. If you want the applications to use the unixODBC driver manager, then download and install unixODBC driver manager release
2.2.14, or 2.3.1 and later. For installing unixODBC, see the unixODBC website http:// www.unixODBC.org
.
Linux 64
The 64 Bit Linux driver is LSB 4.1 compliant and is tested on 64 Bit RHEL 6.2, 6.3 and A standard Linux installation is required for the driver. If you want the applications to use the unixODBC driver manager, then download and install unixODBC driver manager release
2.2.14, or 2.3.1 and later. For installing unixODBC, see the unixODBC website http:// www.unixODBC.org
.
Windows
The following table lists the installation requirements for the Windows driver:
Component
Memory
Disk space
Operating System
Driver Manager
Browser
Installation requirement
Minimum 32 MB
Minimum 30 MB additional free space
ANSI driver: Microsoft Windows NT 4.0, Windows 98,
Windows 2000, Windows 2003 or Windows XP,
Windows Vista, and Windows 7 nl
Unicode driver: Windows 2003, Windows XP Service
Pack2 or later, Windows Vista, and Windows 7
Microsoft ODBC version 3.51 or later
Microsoft Internet Explorer 4.0 or later; HP recommends version 8.0
Installation procedures
HP-UX
Perform the following steps to install the driver:
Installation requirements 17
1.
Download the driver from NonStop system to the HP–UXia64 workstation in binary mode
(You can use FTP utility for downloading). The driver is packaged as a tar file in the
Software Update Tape (SUT) and is available on the NonStop system when DSM/SCM is used to install the SUT. The file name is ODBC64HI, and is located in the volume
$SYSTEM.ZMXODBC
.
2.
Log on to the HP–UXia64 workstation as a root user.
3.
Go to download directory, and enter the following command to extract the files: tar -xvf ODBC64HI
The files are extracted to HPUXia64_ODBC_64 directory. The install scripts and the
README file are also extracted with the driver.
4.
Go to the HPUXia64_ODBC_64 directory.
5.
To start the installation, enter the following command:
./runme.sh
6.
Enter 1 and press Enter. If you have already installed the driver, a warning message appears.
The library files are installed in the /usr/lib/hpux64 directory and a sample MXODSN file is copied to the /etc/mxodbc directory. Upon successful installation, the following message is displayed:
Installed !
Linux 32
Perform the following steps to install the driver:
1.
Download the driver from NonStop system to the Linux workstation in binary mode (You can use FTP utility for downloading). The driver is packaged as a tar file in the Software
Update Tape (SUT) and is available on the NonStop system when DSM/SCM is used to install the SUT. The file name is LODBCTAR, and is located in the volume
$SYSTEM.ZMXODBC
.
2.
Log in to the Linux workstation as a root user.
3.
Go to download directory, and enter the following command to extract the files: tar -xvf LODBCTAR
The files are extracted to Linux_ODBC_32 directory. The install scripts and the README file are also extracted with the driver.
4.
Go to the Linux_ODBC_32 directory.
5.
To start the installation, enter the following command:
./runme.sh
6.
Enter 1 and press Enter. If you have already installed the driver, a warning message appears.
The library files are installed in the /usr/lib directory and a sample MXODSN file is copied to the /etc/hpodbc directory. Upon successful installation, the following message is displayed:
Installed !
Linux 64
Perform the following steps to install the driver:
1.
Download the driver from NonStop system to the Linux workstation in binary mode (You can use FTP utility for downloading). The driver is packaged as a tar file in the Software
Update Tape (SUT) and is available on the NonStop system when DSM/SCM is used to install the SUT. The file name is LODBC64, and is located in the volume
$SYSTEM.ZMXODBC
.
2.
Log in to the Linux workstation as a root user.
18 Installing the drivers
3.
Go to download directory, and enter the following command to extract the files: nl tar -xvf LODBC64
The files are extracted to 64Linux_ODBC_321 directory. The install scripts and the
README file are also extracted with the driver.
4.
Go to the 64Linux_ODBC_321 directory.
5.
To start the installation, enter the following command: ./runme.sh
6.
Enter 1 and press Enter. If you have already installed the driver, a warning message appears.
The library files are installed in the /usr/lib64 directory and a sample MXODSN file is copied to the /etc/hpodbc directory. Upon successful installation, the following message is displayed:
Installed !
Windows
Perform the following steps to install the ANSI or Unicode drivers:
1.
Close all other applications.
2.
Log in to the Windows workstation as an administrator.
3.
Create a temporary installation folder to download the installation file. For example, C:\
ODBCTEMP
.
4.
Use FTP to download the following files from the $SYSTEM.ZMXODBC installation subvolume:
•
ANSI TDMODBC or the Unicode ODBCW32 file for 32–bit driver install
•
ANSI NSODBC64 or the Unicode ODBCW64 file for 64–bit driver install
5.
Rename the files with .EXE extension. For example, TDMODBC.EXE.
6.
Double click TDMODBC.EXE, NSODBC64.EXE, ODBCW32.EXE, or ODBCW64.EXE to launch the Installation Wizard.
7.
Click the Next button on the Welcome Screen.
8.
Accept the License Agreement and click Next.
9.
You can retain the default or change the Destination Folder on the following screen by clicking the Browse button. Click Next.
Installation procedures 19
10. You can retain the default or provide a different Program Folder on the following screen:
Click Next.
11. You can see the installation progress in the Setup Status progress bar.
After a successful installation, the following screen appears:
20 Installing the drivers
12. Click Finish.
NOTE:
•
HP recommends that you restart the PC before you use the ODBC/MX client interface.
•
When the installation is complete, delete the temporary installation folder.
Verifying the installation
HP-UX
After a successful installation, the following files are installed:
•
/usr/lib/hpux64/libmxodbc_ia64.sl
•
/usr/lib/hpux64/libmxodbc_ia64_drvr.sl
•
/usr/lib/hpux64/libhpsecClient64.sl
•
/etc/mxodbc/MXODSN
The checksum of the shared libraries must match the checksum in the md5sum file. If the library is not present in the default location (/usr/lib/hpux64), ensure that the location of the driver
(libmxodbc_ia64.sl, libmxodbc_ia64_drvr.sl, libsecClient64.sl ) is set in the environment variable SHLIB_PATH.
To set the SHLIB_PATH variable, enter the following command: export SHLIB_PATH = < directory, where the driver is located >
Linux 32
After a successful installation, the following files are installed:
•
/usr/lib/libmxodbc.so
•
/usr/lib/libmxodbc.so.3
•
/usr/lib/libmxodbc.so.3.2.1
•
/usr/lib/libmxodbc_l_drvr.so
Verifying the installation 21
•
/usr/lib/libmxodbc_l_drvr.so.3
•
/usr/lib/libmxodbc_l_drvr.so.3.2.1
•
/usr/lib/libhpsecClient.so
•
/etc/hpodbc/MXODSN
The checksum of the shared libraries must match the checksum in the md5sum file.
Linux 64
After a successful installation, the following files are installed:
•
/usr/lib64/libmxodbc64.so
•
/usr/lib64/libmxodbc64.so.3
•
/usr/lib64/libmxodbc64.so.3.2.1
•
/usr/lib64/libmxodbc64_l_drvr.so
•
/usr/lib64/libmxodbc64_l_drvr.so.3
•
/usr/lib64/libmxodbc64_l_drvr.so.3.2.1
•
/usr/lib64/libhpsecClient64.so
•
/etc/hpodbc/MXODSN
The checksum of the shared libraries must match the checksum in the md5sum file.
Windows
After a successful installation of ANSI driver, the following files are installed in Windows System folder:
• tdm_oadm0300.dll
,
• tdm_odbc0300.dll
• tdm_odbcDrvMsg_intl0300.dll
• tdm_OdbcTrace0300.dll
• tdm_ores0300.dll
• tdm_tcpipv40300.dll
• tdm_tcpipv60300.dll
• tdm_translation.dll
After a successful installation of Unicode driver, the following files are installed in Windows
System folder:
• tdm_oadmw0300.dll
,
• tdm_odbcw0300.dll
• tdm_odbcDrvMsg_intlw0300.dll
• tdm_OdbcTracew0300.dll
• tdm_oresw0300.dll
• tdm_tcpipv4w0300.dll
• tdm_tcpipv6w0300.dll
• tdm_translationw.dll
Uninstalling the driver
HP-UX
Perform the following steps to uninstall the driver:
22 Installing the drivers
1.
Log in to the HP-UXia64 workstation as a root user.
2.
Go to the HPUXia64_ODBC_64 directory.
3.
To uninstall the driver, enter the following command:
./runme.sh
4.
Enter 2 and press Enter. Enter yes if you want to continue with uninstall operation.
5.
Enter yes if you want to remove the configuration files.
6.
Upon successful uninstallation, the following message is displayed:
UnInstalled !
Linux 32
Perform the following steps to uninstall the driver:
1.
Log in to the Linux workstation as a root user.
2.
Go to the Linux_ODBC_32 directory.
3.
To uninstall the driver, enter the following command:
./runme.sh
4.
Enter 2 and press Enter. Enter yes if you want to continue with uninstall operation.
5.
Enter yes if you want to remove the configuration files.
6.
Upon successful uninstallation, the following message is displayed:
UnInstalled !
Linux 64
Perform the following steps to uninstall the driver:
1.
Log in to the Linux workstation as a root user.
2.
Go to the 64Linux_ODBC_321 directory.
3.
To uninstall the driver, enter the following command: nl
./runme.sh
4.
Enter 2 and press Enter. Enter yes if you want to continue with uninstall operation.
5.
Enter yes if you want to remove the configuration files.
6.
Upon successful uninstallation, the following message is displayed: nl
UnInstalled !
Windows
You can uninstall the ANSI or Unicode client interface using one of the following methods:
•
Select Start -> Programs -> Release -> Remove Release.
Release can be NonStop ODBCMX <version> or NonStop ODBCMX <version>
Unicode
.
Click Yes.
•
Run TDMODBC.EXE or NSODBC64.EXE for ANSI driver, and ODBCW32.EXE or
ODBCW64.EXE
for Unicode driver, and select Uninstall.
NOTE: The uninstall operation deletes the driver, but it does not delete the driver manager or data sources. You cannot use these data sources until you reinstall the driver.
Uninstalling the driver 23
3 Configuring data sources
This chapter describes the various procedures to configure the SQL/MX data sources.
•
“Configuring a client data source”
•
“Configuring the drivers for IPv6”
•
“Configuring a secure ODBC connection using NonStop SSL”
•
“MXODSN and ODBCDSN file formats”
•
•
“Managing transactions” (page 34)
•
Configuring a client data source
Unix
The MXODSN file on HP-UX and Linux, or the ODBCDSN file on OSS, which is a text file, is a repository of all client data sources.
You can place the MXODSN or ODBCDSN file in any one of the following locations; the search order for these files are also mentioned:
1.
Directory specified in DSN_PATH environment variable
2.
ODBC application directory
3.
Default system location
•
On HP-UX, /etc/mxodbc
•
On Linux32 and Linux64, /etc/hpodbc
•
On OSS, /G/system/system, which is the OSS name for the Guardian location
To configure a client data source, edit the MXODSN or ODBCDSN file. Change this file so that the attributes are set to the correct values for your system (for example, names of data sources and attributes describing them).
The DSN in the MXODSN or ODBCDSN file must exactly match the server data source name
(data source names are case sensitive). If the data source names do not match, the application gets a warning that connection is established with the default data source,
TDM_Default_DataSource
.
If you have not defined the CATALOG and SCHEMA attributes in the MXODSN or ODBCDSN files, the driver uses the default values.
Windows
Perform the following steps to add a client data source:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Click Add to add a new data source. To configure a data source, get the list of data source names by clicking either the System DSN or the User DSN tab.
3.
Choose NonStop(TM) ODBCMX < Release > from the list, and then click Finish. < Release
> is version or Unicode version.
4.
Enter the details in the Create Data Source screens.
Perform the following steps to configure a client data source:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Click either the System DSN or the User DSN tab to get the list of data sources.
24 Configuring data sources
3.
Select the data source name that you want to configure and click Configure.
4.
Each tab in the configuration view displays different fields in the data source configuration.
Make the required changes.
For more information about the Microsoft ODBC Data Source Administrator screens and tabs, click Help.
NOTE:
•
While creating a new data source, ensure the following special characters are not part of the data source name:
\, /, :, *, ?, “, <, >, |
•
When creating a new client data source, ensure that it matches that of a server data source name and have the matching case. If a client data source name does not exist on the server, the default server data source, TDM_Default_DataSource is used.
The following connection string is used to configure the client data source:
"DSN=< DataSource name>;catalog=<catalog_name>; schema=<schema_name>;
Uid=<userid>;Pwd=<password>;FETCHBUFFERSIZE=<value in bytes>; SQLFRACTIONVALUE=<value>;ATTR_CONNECTION_TIMEOUT=<value in seconds>;
SQL_LOGIN_TIMEOUT=<value in seconds>;SQL_QUERY_TIMEOUT=<value in seconds>”; nl
For more information about the attributes, see
MXODSN and ODBCDSN file formats
.
explains the driver connection attributes specific to Windows driver:
Table 2 Connection attributes
Attribute
DSN
FILEDSN
SAVEFILE
DRIVER
ERRORMSGLANG
CTRLINFERNCHAR
TRANSLATIONDLL
Description
Name of the data source as returned by
SQLDataSources
API or the data sources dialog box of SQLDriverConnect API.
Name of a .dsn file. The driver builds the connection string for the data source with the information stored in this file.
The file name of a .dsn file. The attribute values of keywords used for the successful connection are saved in this file.
Description of the driver as returned by the SQLDrivers
API. For example, Rdb or SQL Server.
Client error message language. This is equal to
SYSTEM_DEFAULT. The default is ENGLISH.
Used for setting Infer charset, default is
SYSTEM_DEFAULT, which is the client local character set.
Translates the data from one character set to other. Set the TRANSLATIONDLL in either of the following ways:
• TRANSLATIONDLL=tdm_translation.dll
• Click Browse to select a DLL.
The DLL you specify is used to map the character set for a particular language.
TRANSLATIONOPTION
Options supported by the translation DLL.
NOTE: If DSN attribute is not provided in the connection string, the driver uses the SERVERDSN as the default DSN.
Configuring a client data source 25
Configuring the drivers for IPv6
HP-UX, Linux 32 and Linux 64
You can directly enter the IPv6 address instead of IPv4 address in the MXODSN or odbc.ini
(when using the unixODBC driver manager) configuration files. The driver recognizes the IPv6 address format and connects to the server.
The following is a sample from the configuration file:
Server = TCP: 2620:0:a17:e03e:a00:8eff:fe08:cd65:3033
OSS
Perform the following steps for the driver to use IPv6:
1.
Ensure that the TCPIP DEFINE is set to use IPv6 when you start the application. The value,
IPv6 is case sensitive.
2.
Add the TCPIP^PROCESS^NAME DEFINE.
•
Delete the existing DEFINE using the following command: del_define =TCPIP^PROCESS^NAME
•
Add the DEFINE using the following command:
PARAM TCPIP^PROCESS^NAME $<TCPSAM-process-name> add_define =TCPIP^PROCESS^NAME, class MAP, file “<system-name>.$<TCPSAM-process-name>”
For more information, see the TCP/IPv6 Configuration and Management Manual.
3.
Start the OSH or OSS process. If the process is started directly, the environmental variable
TCPIP_PROCESS_NAME must point to IPv6 process.
Windows
Perform the following steps for the ANSI or Unicode driver to use IPv6:
1.
Select Start -> Programs -> Release.
Release can be NonStop ODBCMX <version> or NonStop ODBCMX <version>
Unicode
.
2.
Create or modify a DSN.
3.
Select the Network tab to enter the IPv6 address in the MXCS IP Address field.
IPv6 is not supported for the driver through HP SSL. For more information about SSL, see the
HP NonStop SSL Reference Manual.
NOTE: The SSL ODBC/MX and MXOAS processes must run on the same TCP/IP process.
TargetPort must not be specified with HP NonStop SSL REMOTE PROXY SETUP macro.
Configuring a secure ODBC connection using NonStop SSL
Perform the following tasks to encrypt the ODBC connection by using NonStop SSL with Windows driver:
1.
Install a NonStop SSL Server process for the ODBC/MX Association Server for the target
MXCS subsystem.
2.
Install the RemoteProxy software and configure Remote Proxy to route ODBC connections to the NonStop SSL Server process.
3.
Modify the connection attributes of client data source for Windows drivers to connect to Remote
Proxy.
Installing a NonStop SSL Server process for ODBC/MX
Installing a NonStop SSL Server process is restricted to the super.super user.
Perform the following steps on the NonStop server to install a NonStop SSL Server process for
ODBC/MX:
26 Configuring data sources
1.
Log on as super.super.
2.
Enter the following command to change to the NonStop SSL directory:
$SYSTEM STARTUP 1> volume $system.znsssl
3.
Enter the following command at the TACL prompt to start the setup:
$SYSTEM ZNSSSL 10> run $SYSTEM.ZNSSSL.SETUP
4.
Enter [7] to select ODBC/MX server in run mode.
5.
Enter the home terminal. The default value is $YMIOP.#CLCI.
6.
Enter the CPU on which you want to run SSL. The default value is CPU 3.
7.
Enter the SSL process name. The default value is $ODBS3.
8.
Enter the TCP/IP process name for the subnet on which the ODBC/MX MXCS service runs.
The default value is $ZTC0.
9.
Enter a port number for the SSL ODBC/MX connection. The default port number is 8402.
10. Enter y or n to specify whether the startup and error messages must be sent to EMS.
11. Enter a name for the SCF IN file for the ODBCMXS configuration. The default value is ODBSIN3.
12. Enter a name for the SCF configuration file for the ODBCMXS configuration. The default value is ODBSCF3.
13. The following message indicates that SSL configuration successfully created the script files.
These script files are used to configure and start the process as a kernel managed persistent process.
**** SETUP has completed successfully ****
Files created: <SCF IN file> and <SCF configuration file>.
14. Enter the following command to configure NonStop SSL as a persistent process:
$SYSTEM ZNSSSL 11> SCF/IN <SCF IN filename>
For example, if you use the default name, the command is SCF/IN ODBSIN3.
15. Enter the following command to start the process :
$SYSTEM ZNSSSL 12> SCF START PROCESS $ZZKRN.#SSL-ODBCMXS-3
16. Enter the following command to check whether the process started correctly:
$SYSTEM ZNSSSL 13> SHOWLOG ODBSLOG *
The log file must contain a message similar to the following sample:
$ODBS3|05Mar12 09:54:19.89|20|ODBC/MX server proxy started on target host 127.0.0.1, target port 23, source port 8402 $ODBS3|05Mar12 09:54:19.93|50|Performed action
CombinedAction(CreateSocket,ListenSocketAction) successfully.
The host NonStop SSL Server process is now running and available for client access.
For more information about installing the NonStop SSL Server process for ODBC/MX, see the HP
NonStop SSL Reference Manual.
Installing and configuring the Remote Proxy Client
You must obtain the following information from your administrator before installing the Remote
Proxy Client:
•
The IP address, host name, and port number of the SSL server running on the NonStop system.
•
The port number of the MXCS Association Server that you want to connect.
NOTE: The MXCS Association Server port number must not be in use by any other program or service on your client workstation.
For information about obtaining the port number, see the SQL/MX Connectivity Service
Administrative Command Reference.
Perform the following steps to install and configure the Remote Proxy client on Windows workstation:
Configuring a secure ODBC connection using NonStop SSL 27
1.
Download the $SYSTEM.ZNSSSL.PROXYEXE file in binary format and rename it to
PROXY.EXE
.
2.
Run PROXY.EXE to start the RemoteProxy installation program, and follow the installation instructions in the wizards.
3.
Double-click the NonStop SSL RemoteProxy icon in your system tray. The RemoteProxy configuration window is displayed.
4.
Select Session –> New. The HP NonStop SSL RemoteProxy dialog is displayed.
1.
Select ODBCMX Client in the Protocol menu.
2.
Enter the IP address or host name of the system where the MXCS Association Server process is running, in the Target Information field.
3.
Enter the port number of the SSL server in the Target (Connecting) Port field. For example, 8402.
4.
Enter the port number of the MXCS Association Server in the Local (Accepting)
Port field.
5.
Click Start to start the Remote Proxy session.
6.
Check the startup messages to verify that the Remote Proxy session started successfully.
Configuring a client data source for NonStop SSL
Perform the following steps to configure a client data source on your workstation:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Click either the System DSN or the User DSN tab to get the list of data sources.
3.
Select the data source name that you want to configure and click Configure.
4.
Change the MXCS IP Address in Network tab to localhost in the screen shot after table
3.
5.
Go to Testing tab and click Test Connection to test the connection. Upon successful connection,
Connected Successfully message is displayed.
28 Configuring data sources
DataSource configuration in Windows driver
DataSource configuration in Windows driver 29
MXODSN and ODBCDSN file formats
The following table describes the various sections in the MXODSN and ODBCDSN files.
Table File sections
File Section
[ODBC]
[ODBC Data Sources]
Data source specification
[DataSourceName]
Description
This section lists the tracing options.
This section lists the data sources.
Each DSN listed in the [ODBC Data Sources] section must have this section that describes the DSN.
Associates a driver with the DSN.
describes the MXODSN and ODBCDSN attributes.
Table 4 MXODSN and ODBCDSN attributes
File Section
[ODBC]
Attributes
TraceStart
Description
TraceStart can have two values, 0 or 1. If set to 0, tracing is off. If set to
30 Configuring data sources
Table 4 MXODSN and ODBCDSN attributes (continued)
File Section Attributes
[ODBC Data Sources]
[data-source-name]
, one section for each DSN
TraceFlags
TraceFile
DSN
= description
[DataSourceName]
Description
DataLang
FetchBufferSize
Server
SQLFractionValue
SQLIntervalBehaviour
Description
1, tracing is on. By default, tracing is off.
TraceFlags indicates the trace level.
It can have the following values:
•
ERROR to trace failed SQL calls and communication problems.
•
WARNING to trace the warnings.
•
CONFIG to trace configuration calls.
•
INFO to trace details about calls made.
•
DEBUG to trace the internal details about calls made for debugging an issue.
TraceFile attribute indicates the trace file name. The trace file is located in the ODBC application directory. For example, if you specify the TraceFile as Tracefile = trfetch, the trace file is created as trfetch.6947088_1285815329
on
Linux systems.
List of data sources, in the format DSN
= description.
[DataSourceName] attribute indicates the driver.
Description attribute describes the data source.
DataLang attribute indicates the character set for SQL commands. The default is 0.
FetchBufferSize indicates the buffer size to fetch rows. The range is between 0 and 256 Kb. If set to
SYSTEM_DEFAULT, the buffer size is 8
Kb (SYSTEM_DEFAULT). For a single row, the value is 0.
Server attribute indicates the IP address or domain name where MXCS is running. The format is
TCP:number1:number2.
SQLFractionValue indicates the fraction value for SQL_C_TIMESTAMP to be in nanoseconds or microseconds.
If set to 9, the fraction value is in nanoseconds. If set to SQL_DEFAULT, not specified, or set to a value other than 9, the fraction value is in microseconds. For more information, see
“Timestamp values with fraction”
SQLIntervalBehaviour includes zeroes at the beginning or at end of an interval datatype for micro or nano
MXODSN and ODBCDSN file formats 31
Table 4 MXODSN and ODBCDSN attributes (continued)
File Section Attributes
[DataSourceName]
SQLDatetimeRetrieval
SQL_ATTR _CONNECTION
_TIMEOUT
SQL_LOGIN _TIMEOUT
SQL_QUERY _TIMEOUT
Catalog
Schema
AUTOCOMMIT
Driver = driver
Description seconds. SQLIntervalBehaviour has two values, SYSTEM_DEFAULT and
MSDN_DEFAULT. If not specified, the default is SYSTEM_DEFAULT. For more information, see
.
SQLDatetimeRetrieval specifies how the SQL/MP Datetime data type is retrieved from the driver.
SQLDatetimeRetrieval has two values, SYSTEM_DEFAULT and
MSDN_DEFAULT. If not specified, the default is SYSTEM_DEFAULT. For more information, see
.
SQL_ATTR_CONNECTION_TIMEOUT indicates the wait time to close an idle connection. If set to SYSTEM_DEFAULT, the value is 60 seconds. If set to -1, use the ConnTimeout value set on the
MXCS server data source. If set to
NO_TIMEOUT, the driver waits until a
ODBC server becomes available or
MXCS is stopped.
SQL_LOGIN_TIMEOUT indicates the wait time to establish a connection with
MXCS. If set to SYSTEM_DEFAULT, the value is 60 seconds. If set to
NO_TIMEOUT, the driver waits until a connection is established with MXCS.
SQL_QUERY_TIMEOUT indicates the wait time to close the cursor and return control to the ODBC application. If set to SYSTEM_DEFAULT, the value is 60 seconds. If set to NO_TIMEOUT, the driver waits till the query completes.
Catalog indicates the catalog name.
If not specified, the driver uses the
MXCS defined catalog name.
Schema indicates the schema name. If not specified, the driver uses the MXCS defined schema name.
The values for AutoCommit can be
SERVER_DEFAULT
, ON, and OFF. For more information, see
“Managing transactions” (page 34)
.
List of drivers.
This value must match the driver name defined by DataSourceName attribute in the [ODBC Data Sources] section.
The following sample MXODSN file defines connections to three client data sources;
TDM_Default_DataSource
, DS1, and DS2:
In this example, the attributes Catalog and Schema for data source DS1 are defined as DS1CAT and DS1SCH.
32 Configuring data sources
[ODBC]
TraceFlags = 6
TraceStart = 0
TraceFile = trlog
[ODBC Data Sources]
TDM_Default_DataSource = NonStop ODBC/MX 3.x
DS1 = NonStop ODBC/MX 3.x
DS2 = NonStop ODBC/MX 3.x
DataSourceName = Driver
[TDM_Default_DataSource]
Description = Default Data Source
Catalog = CAT
Schema = SCH
DataLang = 0
FetchBufferSize = SYSTEM_DEFAULT
Server = TCP:xxx.xxx.xxx.xxx:xxxx
SQL_ATTR_CONNECTION_TIMEOUT = SYSTEM_DEFAULT
SQL_LOGIN_TIMEOUT = SYSTEM_DEFAULT
SQL_QUERY_TIMEOUT= NO_TIMEOUT
[DS1]
Description = Sample Data Source 1
Catalog = DS1CAT
Schema = DS1SCH
Server = TCP:xxx.xxx.xxx.xxx:xxxx
SQLIntervalBehaviour = SYSTEM_DEFAULT
SQLDatetimeRetrieval = SYSTEM_DEFAULT
[DS2]
Description = Sample Data Source 2
Catalog = DS2CAT
Schema = DS2SCH
SQLIntervalBehaviour = SYSTEM_DEFAULT
[DataSourceName]
Driver = NonStop ODBC/MX
Managing data sources
Unix
To add a new DSN entry in the MXODSN or ODBCDSN file, include the DSN and its description.
If the values of the attributes are not specified in the MXODSN or ODBCDSN file, the driver uses the default values when creating a connection.
Perform the following steps to modify or delete a DSN entry:
1.
Modify the attributes or remove the DSN entry, and save the file.
2.
Restart the application to reflect the changes.
Managing data sources 33
Windows
To add a new data source or configure an existing data source, see
“Configuring a client data source”
.
Perform the following steps to delete a client data source:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Click either the System DSN or the User DSN tab to get the list of data sources.
3.
Select the data source name that you want to delete and click Remove.
4.
Click Yes in the confirmation dialog box to remove the data source.
Managing transactions
The AutoCommit property indicates whether SQL/MX must automatically commit the transaction nl or not.
The following are the valid values for AutoCommit property:
•
ON
•
OFF
•
SERVER_DEFAULT specifies to use the server side AutoCommit settings. This option is useful for existing applications where AutoCommit is set on the server side data source and the user wants to persist with the same settings without making any changes to the client application or client side data source. This is the default option.
AutoCommit property can be set in the following ways:
•
Using SQLSetConnectAttr API, the values are ON/OFF.
•
Using DSN properties, the values are SERVER_DEFAULT/ON/OFF.
•
Using connection string without DSN, the values are ON/OFF/SERVER_DEFAULT.
NOTE: The value set using SQLSetConnectAttr API takes the highest precedence.
Setting AutoCommit
Windows driver
You can set the AutoCommit property from the Data Access tab.
Unix drivers
AUTOCOMMIT (case sensitive) is the keyword to set AutoCommit property in property file
(MXODSN for Linux and HP-UX, ODBCDSN for OSS).
Example 1 Depicting AUTOCOMMIT set to SERVER_DEFAULT
[TDM_Default_DataSource]
Description = Default Data Source
Catalog = CAT
Schema = SCH
DataLang = 0
FetchBufferSize = SYSTEM_DEFAULT
Server = TCP:hostname/portnumber
SQL_ATTR_CONNECTION_TIMEOUT = SYSTEM_DEFAULT
SQL_LOGIN_TIMEOUT = SYSTEM_DEFAULT
SQL_QUERY_TIMEOUT = NO_TIMEOUT
SQLFractionValue = SYSTEM_DEFAULT
SQLDatetimeRetrieval = MSDN_DEFAULT
AUTOCOMMIT = SERVER_DEFAULT
34 Configuring data sources
Using connection string without DSN
You can set AUTOCOMMIT as part of the Connection string.
“AutoCommit=ON/OFF/SERVER_DEFAULT”.
Example 2 Depicting AUTOCOMMIT set to ON
Driver={NonStop(TM)ODBCMX 3.2};
ServerDSN = TDM_Default_DataSource;
SERVER =TCP:<hostname/port>;
UID=<userid>;
PWD=<password>;
AutoCommit=ON;
..,..,.,,.,
NOTE: For Windows driver, if AutoCommit property is set to OFF without using
SQLSetConnectAttrAPI
, then the application must execute the commit/rollback as a statement to end an active transaction. SQLEndTrans API cannot be used in this scenario.
Tracing
Unix
You can enable or disable tracing by modifying the TraceStart attribute in MXODSN or
ODBCDSN file. For more information about tracing options, see
MXODSN and ODBCDSN attributes .
NOTE: If tracing is enabled, the global trace flag is set and from then onwards, all the traceable ODBC data is logged in the trace file.
Perform the following steps to enable tracing:
1.
Stop the application.
2.
Set the TraceStart attribute to 1 in the MXODSN or ODBCDSN file, and save.
3.
Start the application.
Perform the following steps to disable tracing:
1.
Stop the application.
2.
Set the TraceStart attribute to 0 in the MXODSN or ODBCDSN file, and save.
3.
Start the application.
Windows
Perform the following steps to configure tracing for ANSI or Unicode drivers:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Click either the System DSN or the User DSN tab to get the list of data sources.
3.
Select the data source name and click Configure.
4.
Select the Tracing tab.
5.
Choose NonStop ODBCMX API or Network Layer, or both.
6.
Enter a log file name.
7.
Click Apply and then click OK.
Perform the following steps to start tracing:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Select the Tracing tab.
3.
Select the Custom Trace DLL. Use the Select DLL button to locate the correct file.
Tracing 35
If you select the ODBC standard trace DLL (odbctrac.dll from the Windows System folder), only the driver manager is traced; additional trace options that you select are ignored.
If you select the ODBC/MX trace DLL (tdm_odbctrace0300.dll or tdm_odbctracew0300.dll
from the Windows System folder), all trace options that you select for the client data source are considered.
4.
Use the Browse button to locate the correct log file.
5.
Click Start Tracing Now.
6.
Click Apply and then click OK.
Perform the following steps to stop tracing:
1.
Select Start -> Control Panel -> Administrative Tools -> Data Sources
(ODBC)
.
2.
Select the Tracing tab.
3.
Click Stop Tracing Now.
4.
Click Apply and then click OK.
36 Configuring data sources
4 Compatibility and considerations
The drivers are compatible with the following:
•
ODBC 3.5
•
SQL-92 features supported by SQL/MX
For more information about SQL/MX supported scalar and string functions, see the SQL/MX
Reference Manual for Release 3.x.
These subsequent sections list the compatibility of the drivers for the following:
•
•
•
“Unsigned data types” (page 39)
•
“Partial DATE or TIME values” (page 40)
•
“Microsoft escape clauses” (page 41)
•
•
“Transaction and cursor behavior” (page 41)
•
“Timestamp values with fraction” (page 42)
Considerations
lists the considerations.
Table 5 Considerations
Item
ODBC/MX client application
Catalog and schema
SQL_QUERY_TIMEOUT option
SQLCancel
API
SQLPrimaryKeys
API
Consideration
An ODBC client application must be installed on the client workstation.
An application can set the catalog and schema information in the MXODSN file on Linux or ODBCDSN file on OSS. If the application does not set the catalog and schema for the client data source, and no default catalog and schema are defined in MXCS for the server data source, then MXCS, by default, uses NONSTOP_SYSTEM_NSK and PUBLIC_ACCESS_SCHEMA.
NOTE: By default, catalog and schema names are case insensitive and follow SQL/MX rules. Case sensitive catalog and schema names can be specified within quotes.
An application can call SQLSetStmtOption ODBC API with the
SQL_QUERY_TIMEOUT option to specify the wait time for query execution.
The SQL_QUERY_TIMEOUT option protects MXCS and the application from long running queries. If a query exceeds the specified time before the data source returns the result, the driver returns HYT00 (Timeout expired) to the application.
For an ODBC 2.0 application, when the query is not running, the driver implements the SQLCancel API as an SQLFreeStmt with the SQL_CLOSE option. If the query is running, MXCS tries to stop the ODBC server. If the attempt is successful, the application receives an error and must reconnect.
For an ODBC 3.x application with a query (or queries) running, the behavior is the same as for a ODBC 2.0 application. For an ODBC 3.x application with no queries running, the driver does not implement the SQLCancel API.
The application is responsible for closing the cursor.
This API does not support pattern value arguments for table names, and returns keys information for a specified table name in the SQL/MX catalog.
Considerations 37
Table 5 Considerations (continued)
Item
SQLSpecialColumns
API
SQLStatistics
API
Consideration
This API does not support pattern value arguments for table names, and returns an optimal set of columns that the SQLSpecialColumns API uniquely identifies a row in the table information for a specified table name in the
SQL/MX catalog.
This API does not support pattern value arguments for table names, and returns index information for a specified table name in the SQL/MX catalog.
Returns all catalogs defined in the SQL/MX metadata.
SQLTables
API
When CatalogName is
SQL_ALL_CATALOGS
Returns all the schemas defined in the SQL/MX metadata.
SQLTables
API
When SchemaName is
SQL_ALL_SCHEMAS
SQLTables
API
When TableType is
SQL_ALL_TABLE_TYPES
Returns all object types defined in the SQL/MX metadata.
SQL Table Names, SQL Catalog and
Schema Names
SQLBindParameter
API
SQLPutData
API
The drivers use SQL_ATTR_METADATA_ID to determine whether to upshift a table name. This applies for catalog APIs SQLTables, SQLPrimaryKey, and SQLStatistics. This does not apply to SQLColumns API.
For this API, SQL_DEFAULT_PARAM and SQL_LEN_DATA_AT_EXEC (length) are not supported for the pcbValue argument.
This API can send data in parts only for the SQL_LONGVARCHAR data type.
For all other data types, only the latest value in the rgbValue argument is sent.
For information on migrating SQL/MP ODBC client applications to SQL/MX environment, see
SQL/MX Comparison Guide for NonStop SQL/MP Users.
ODBC data types
lists the compatibility of drivers for ODBC data types.
Table 6 ODBC Data Types
ODBC data type
CHAR(n)
VARCHAR(n)
LONGVARCHAR
DECIMAL(p,s)
NUMERIC(p,s)
SMALLINT
INTEGER
REAL
FLOAT(p)
DOUBLE PRECISION
BIT
TINYINT
SQL/MX data Type
CHAR(n)
VARCHAR(n)*
VARCHAR(n)
DECIMAL(p,s)
NUMERIC(p,s)**
SMALLINT
INTEGER
REAL
FLOAT(p)
DOUBLE PRECISION
Not supported
Not supported
SQL/MP data Type
CHAR(n)
VARCHAR(n)*
VARCHAR(n)
DECIMAL(p,s)
NUMERIC(p,s)
SMALLINT
INTEGER
REAL
FLOAT(p)
DOUBLE PRECISION
Not supported
Not supported
Supported by the driver?
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
38 Compatibility and considerations
Table 6 ODBC Data Types (continued)
ODBC data type
TINYINT UNSIGNED
BIGINT
BINARY(n)
VARBINARY(n)
LONG VARBINARY
DATE
TIME(p)
TIMESTAMP
INTERVAL MONTH(p)
INTERVAL YEAR(p)
INTERVAL YEAR(p) TO
MONTH
INTERVAL DAY(p)
INTERVAL HOUR(p)
INTERVAL MINUTE(p)
SQL/MX data Type
Not supported
LARGEINT
Not supported
Not supported
Not supported
DATE
TIME
TIMESTAMP
INTERVAL MONTH(p)
INTERVAL YEAR(p)
INTERVAL YEAR(p) TO
MONTH
INTERVAL DAY(p)
INTERVAL HOUR(p)
INTERVAL MINUTE(p)
INTERVAL SECOND(p) INTERVAL SECOND(p)
INTERVAL DAY(p) TO HOUR INTERVAL DAY(p) TO HOUR
INTERVAL DAY(p) TO
MINUTE
INTERVAL DAY(p) TO
SECOND
INTERVAL DAY(p) TO
MINUTE
INTERVAL DAY(p) TO
SECOND
INTERVAL HOUR(p) TO
MINUTE
INTERVAL HOUR(p) TO
SECOND(q)
INTERVAL MINUTE(p) TO
SECOND(q)
INTERVAL HOUR(p) TO
MINUTE
INTERVAL HOUR(p) TO
SECOND(q)
INTERVAL MINUTE(p) TO
SECOND(q)
SQL/MP data Type
Not supported
LARGEINT
Not supported
Not supported
Not supported
DATE
TIME
TIMESTAMP
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Supported by the driver?
No
Yes
No
No
Yes
Yes
Yes
Yes
* The default size allocated for VARCHAR length is 4K (4096). The VARCHAR length can be up to 4059 for key-sequenced files or 4070 for entry-sequenced files.
** Starting with SQL/MX Release 3.0, the precision of the NUMERIC data type is extended to
128 digits. If the precision is greater than 18 for signed and greater than 9 for the unsigned numeric data type, use the SQLBindParameter API to insert the data and the SQLBindCol API to select the data with the SQL_C_CHAR data type.
Unsigned data types
The behavior of unsigned data types is determined by the ODBC version and the
SQL_ATTR_MSACCESS_VERSION flag setting.
explains the behavior of unsigned data types.
Unsigned data types 39
Table 7 Behavior of unsigned data types
ODBC version
2.0
3.x, when server data source is configured with
SQL_ATTR_MSACCESS_VERSION flag
Behavior
UNSIGNED SMALLINT is promoted to SIGNED INT and
UNSIGNED INT is promoted to BIGINT.
All unsigned data types are promoted to the next signed type.
Partial DATE or TIME values
To use partial DATE or TIME values as parameters, provide these values through the ODBC/MX data type returned.
To fetch partial DATE or TIME values, see the mappings in
. When you fetch partial DATE or TIME value character strings, the values are returned as partial even if the driver returns a full DATE or TIME or TIMESTAMP data type. Default values are returned as a structure (1 for YEAR, MONTH and DAY, and 0 for HOUR, MINUTE, SECOND and FRACTION).
Table 8 SQL/MP to ODBC/MX Date/Time Mappings
SQL/MP data type
DATETIME YEAR
DATETIME YEAR TO MONTH
DATETIME YEAR TO DAY
DATETIME YEAR TO HOUR
DATETIME YEAR TO MINUTE
DATETIME YEAR TO SECOND
DATETIME YEAR TO FRACTION
DATETIME MONTH
DATETIME MONTH TO DAY
DATETIME MONTH TO HOUR
DATETIME MONTH TO MINUTE
DATETIME MONTH TO SECOND
DATETIME MONTH TO FRACTION
DATETIME DAY
DATETIME DAY TO HOUR
DATETIME DAY TO MINUTE
DATETIME DAY TO SECOND
DATETIME DAY TO FRACTION
DATETIME HOUR
DATETIME HOUR TO MINUTE
DATETIME HOUR TO SECOND
DATETIME HOUR TO FRACTION
DATETIME MINUTE
DATETIME MINUTE TO SECOND
ODBC/MX data type
SQL_DATE
SQL_DATE
SQL_DATE
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_DATE
SQL_DATE
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_DATE
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIMESTAMP
SQL_TIME
SQL_TIME
SQL_TIME
SQL_TIMESTAMP
SQL_TIME
SQL_TIME
40 Compatibility and considerations
Table 8 SQL/MP to ODBC/MX Date/Time Mappings (continued)
SQL/MP data type
DATETIME MINUTE TO FRACTION
DATETIME SECOND
DATETIME SECOND TO FRACTION
DATETIME VALUE RETRIEVAL
ODBC/MX data type
SQL_TIMESTAMP
SQL_TIME
SQL_TIMESTAMP
SQL DATETIME RETRIEVAL
Microsoft escape clauses
ODBC/MX accepts Microsoft escape clauses and translates them into equivalent SQL/MX clauses.
lists the SQL/MX equivalents.
Table 9 SQL/MX equivalents for Microsoft escape clauses
Microsoft escape clause
{ d 'date-literal' }
{ t 'time-literal' }
{ ts 'timestamp-literal' }
{ oj join-expression }
{ INTERVAL sign interval-string interval-qualifier }
SQL/MX equivalent
DATE 'date-literal'
TIME 'time-literal'
TIMESTAMP 'timestamp-literal' join-expression
*
INTERVAL sign interval-string interval-qualifier
{ fn scalar-function }
{ call procedure-name... } scalar-function
**
Supported
{ escape 'escape-character' }
{ [?=]call procedure-name... }
Not supported
Not supported
* ODBC syntax does not include nested joins, while SQL/MX does. ODBC/MX extends the
Microsoft syntax for an outer join.
** Functions are controlled by SQLGetInfo. Only SQL/MX native functions are supported.
Stored Procedures
The drivers support NonStop SQL/MX stored procedures, with the following exceptions:
Pointers to cursors, and return codes are not supported
For more information about stored procedures, see the SQL/MX Guide to Stored Procedures in
Java.
Transaction and cursor behavior
The transaction and cursor behavior is determined by the AUTOCOMMIT setting.
lists the transaction and cursor behavior.
Microsoft escape clauses 41
Table 10 Transaction and cursor behavior
AUTOCOMMIT
ON
OFF
SQL/MX behavior Application action
When any open statement reaches end of data or end of cursor, SQL/MX closes all other open statements.
Not applicable
Not applicable The application must explicitly rollback or commit the transaction. All open statements are closed at that time.
Timestamp values with fraction
The SQLFractionValue attribute indicates whether the fraction value for SQL_C_TIMESTAMP data type must be in nanoseconds or microseconds. If set to 9, the fraction value is in nanoseconds. If set to SQL_DEFAULT, not specified, or set to a value other than 9, the fraction value is in microseconds.
includes a set of sample values and expected values in the column of an SQL/MX table in microseconds.
Table 11 Sample values inserted from an application and expected values in microsecond
54
4
987654
87654
7654
654
54
4
987654
87654
7654
654
Fraction value in the application
987654
87654
7654
654
54
4
987654
87654
7654
654
Column type timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3)
0.00005
0.00000
0.9876
0.0876
0.0076
0.0006
0.0000
0.0000
0.987
0.087
0.007
0.000
Expected value in the column of
SQL/MX table
0.987654
0.087654
0.007654
0.000654
0.000054
0.000004
0.98765
0.08765
0.00765
0.00065
42 Compatibility and considerations
Table 11 Sample values inserted from an application and expected values in microsecond (continued)
54
4
987654
87654
7654
654
54
4
Fraction value in the application
54
4
987654
87654
7654
654
Column type timestamp(3) or time(3) timestamp(3) or time(3) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1)
0.0
0.0
0.0
0.0
0.00
0.00
0.9
0.0
Expected value in the column of
SQL/MX table
0.000
0.000
0.98
0.08
0.00
0.00
987654321
87654321
7654321
654321
54321
4321
987654321
87654321
7654321
654321
54321
4321
987654321
87654321
7654321
654321
54321
includes a set of sample values and expected values in the column of an SQL/MX table in nanoseconds.
Table 12 Sample values inserted from an application and expected values in nanoseconds
Fraction value in the application Column type timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4)
0.08765
0.00765
0.00065
0.00005
0.00000
0.9876
0.0876
0.0076
Expected value in the column of
SQL/MX table
0.987654
0.087654
0.007654
0.000654
0.000054
0.000004
0.98765
0.0006
0.0000
Timestamp values with fraction 43
4321
987654321
87654321
7654321
654321
54321
4321
987654321
87654321
7654321
654321
54321
4321
987654321
87654321
7654321
654321
54321
4321
Table 12 Sample values inserted from an application and expected values in nanoseconds (continued)
Fraction value in the application Column type timestamp(4) or time(4) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1) timestamp(1) or time(1)
0.00
0.00
0.00
0.9
0.000
0.98
0.08
0.00
0.0
0.0
0.0
0.0
0.0
Expected value in the column of
SQL/MX table
0.0000
0.987
0.087
0.007
0.000
0.000
includes a set of sample values retrieved by the application when SQLFractionValue is set to SYSTEM_DEFAULT or to a value other than 9.
Table 13 Values retrieved by the application for SYSTEM_DEFAULT setting
Value in the column of the SQL/MX
Table
0.987654
0.087654
0.007654
0.000654
0.000054
0.000004
0.98765
0.08765
0.00765
0.00065
0.00005
0.00000
Column type timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5)
5
0
Fraction value retrieved by the application
987654
87654
7654
654
54
4
98765
8765
765
65
44 Compatibility and considerations
Table 13 Values retrieved by the application for SYSTEM_DEFAULT setting (continued)
0.09
0.00
0.9
0.0
0.087
0.008
0.000
0.98
Value in the column of the SQL/MX
Table
0.9876
0.0876
0.0076
0.0007
0.0000
0.987
Column type timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(1) or time(1) timestamp(1) or time(1)
9
0
9
0
87
8
0
98
76
7
0
987
Fraction value retrieved by the application
9876
876
includes a set of sample values retrieved by the application when SQLFractionValue is
9. The values are in nanoseconds.
Table 14 Sample values retrieved by the application
0.08765
0.00765
0.00065
0.00006
0.00000
0.9876
0.0876
0.0076
Value in the column of the SQL/MX
Table
0.987654
0.087654
0.007654
0.000654
0.000054
0.000004
0.98765
0.0007
0.0000
Column type timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(6) or time(6) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(5) or time(5) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4) timestamp(4) or time(4)
Fraction value retrieved by the application
987654000
87654000
7654000
654000
54000
4000
987650000
87650000
7650000
650000
60000
0
987600000
87600000
7600000
700000
0
Timestamp values with fraction 45
Table 14 Sample values retrieved by the application (continued)
Value in the column of the SQL/MX
Table
0.987
0.087
0.008
0.000
0.98
0.09
0.00
0.9
0.0
Column type timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(3) or time(3) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(2) or time(2) timestamp(1) or time(1) timestamp(1) or time(1)
Fraction value retrieved by the application
987000000
87000000
8000000
0
980000000
90000000
0
900000000
0
NOTE: The applications can insert the time and timestamp values into the time and timestamp columns of SQL/MX table, using the FRACTION_STRUCT structure. The structure fields are: struct FRACTION_STRUCT {
SQLUINTEGER day,
SQLUINTEGER hour,
SQLUINTEGER minute,
SQLUINTEGER second,
SQLUINTEGER fraction
};
includes a sample set of FRACTION_STRUCT field values when SQL Fraction
Precision Value: is set to 6 or 9.
Table 15 FRACTION_STRUCT field values with SQL Fraction Precision Value: set to 6 or 9.
Table precision/ fraction
123456
12345
1234
123
12
1
6
123456
012345
001234
000123
000012
000001
5
12345
12345
01234
00123
00012
00001
4
1234
1234
1234
0123
0012
0001
3
123
123
123
123
012
001
12
12
12
01
2
12
12
1
1
1
1
1
1
1
SQL Interval Behaviour property
The SQL Interval Behaviour property includes zeroes at the beginning or end of an interval datatype for micro or nano seconds. The SQL Interval Behaviour has two values:
•
SYSTEM_DEFAULT
— Trailing zeroes are added to the fraction. For example, 0.1234 changes to 0.123400.
•
MSDN_DEFAULT
— Leading zeroes are added to the fraction. For example, 0.1234 changes to 0.001234.
46 Compatibility and considerations
If not specified, the default is SYSTEM_DEFAULT.
Set the SQL Interval Behaviour property using the MXODSN property.
•
The following example describes when the value of SQL Interval Behaviour is set to
SYSTEM_DEFAULT
, the behavior of the drivers is same as in earlier releases of SQL/MX. In this example, zeroes are suffixed in the following way:
For example, create table interval_frac
(
ID2S interval day to second,
ID2S0 interval day to second (0),
ID2S1 interval day to second (1),
ID2S2 interval day to second (2),
ID2S3 interval day to second (3),
ID2S4 interval day to second (4)
)
For the above DDL, when you insert values for all columns as 11 22:33:44.1 and 02
11:21:12.1234
binding to valid datatypes, the values are inserted as follows:
Table 16 SQL Interval Behaviour property set to SYSTEM_DEFAULT
ID2S
11
22:33:44.100000
11
22:33:44.123400
ID2S0
11 22:33:44
11 22:33:44
ID2S1
11 22:33:44.1
11 22:33:44.1
ID2S2
11
22:33:44.10
11
22:33:44.12
ID2S3
11
22:33:44.100
11
22:33:44.123
ID2S4
11
22:33:44.1000
11
22:33:44.1234
•
The following example describes when the SQL Interval Behaviour property is set to
MSDN_DEFAULT
. In this example, zeroes are prefixed in the following way:
For example, create table interval_frac
(
ID2S interval day to second,
ID2S0 interval day to second (0),
ID2S1 interval day to second (1),
ID2S2 interval day to second (2),
ID2S3 interval day to second (3),
ID2S4 interval day to second (4)
)
For the above DDL, when you insert values for all columns as 11 22:33:44.1 and 02
11:21:12.1234
binding to valid datatypes, the following values are inserted:
Table 17 SQL Interval Behaviour property set to MSDN_DEFAULT
ID2S
11
22:33:44.000001
11
22:33:44.001234
ID2S0
11 22:33:44
11 22:33:44
ID2S1
11 22:33:44.1
11 22:33:44.1
ID2S2
11
22:33:44.01
11
22:33:44.12
ID2S3
11
22:33:44.001
11
22:33:44.123
ID2S4
11
22:33:44.0001
11
22:33:44.1234
NOTE: In the above examples, the SQL Fraction Precision Value is set to
SYSTEM_DEFAULT
(microseconds).
SQL Interval Behaviour property 47
SQL Datetime Retrieval property
The SQL Datetime Retrieval specifies how the SQL/MP Datetime data type is retrieved from the drivers. The SQL Datetime Retrieval has two values:
•
SYSTEM_DEFAULT
— Year is set to 0001.
•
MSDN_DEFAULT
— Year is set to 1900.
If not specified, the default is SYSTEM_DEFAULT. This property is applicable only when SQL/MP
Datetime datatype is bound to SQL/MX datatypes such as DATE or TIMESTAMP.
Set the SQL Datetime Retrieval property using the MXODSN property.
•
If the value of SQL Datetime Retrieval is set to SYSTEM_DEFAULT, the behavior of the drivers is the same as in earlier releases of SQL/MX.
For example,
1.
Create a table in SQL/MP with Datetime column as month to day.
2.
Insert the data 12–31 into the table using SQL/MX or SQL/MP.
3.
Retrieve the column data from the driver by binding to DATE. The retrieved value is
0001-12-31
.
•
If the value of SQL Datetime Retrieval is set to MSDN_DEFAULT, there is a change in the behavior of the driver when compared to earlier releases of SQL/MX.
For example,
1.
Create a table in SQL/MP with Datetime column as month to day.
2.
Insert the data 12–31 into the created table using SQL/MX or SQL/MP.
3.
Retrieve the column data from the driver by binding to DATE. The retrieved value is
1900-12-31
.
48 Compatibility and considerations
5 Error messages
lists the driver error codes and error messages.
Table 17 Error codes and error messages
Error codes
01000
01000
01002
01004
01006
01033
01S02
07001
07003
07005
07006
07008
07009
08001
08001
08001
08001
08001
08001
08002
08003
08004
08004
08005
08006
08007
08S01
08S02
Error messages
General Warning.
General Warning. Connected to the default data source.
Disconnect error. Transaction rolled back.
Data truncated.
Privilege not revoked.
TRANSPORT LAYER ERROR.
Option value changed.
Wrong number of parameters.
Dynamic SQL error. Cursor specification cannot be executed.
Dynamic SQL error. Prepared statement is not a cursor specification.
Restricted data type attribute violation.
Dynamic SQL error. Wrong number of bound columns.
The value specified for the argument ColumnNumber was greater than the number of columns in the result set.
No more MXCS servers available to connect.
MXCS services not yet available.
Data source not yet available or not found.
No more ports available to start MXCS servers.
Retry attempts to connect to the data source failed, May be MXCS server not able to register to the MXCS service process.
No more MXCS servers available to connect.
Connection in use.
Connection not open.
Data source rejected establishment of connection since the
MXCS server is connected to a different client now.
Data source rejected establishment of connection for implementation defined reasons.
Communication failure.
Transaction rolled back.
Connection failure during transaction.
Communication link failure.
TRANSPORT LAYER ERROR.
49
22018
23000
24000
25000
26000
28000
28000
21S02
22001
22003
22005
22008
22012
22015
42000
70100
S0001
S0002
S0011
S0012
S0021
S0022
S1000
S1000
S1000
Table 17 Error codes and error messages (continued)
Error codes
21001
21002
21S01
34000
37000
3C000
40001
Error messages
Cardinality violation; insert value list does not match column list.
Cardinality violation; insertion value list does not match column list.
Cardinality violation; parameter list does not match column list.
String data right truncation.
Numeric value out of range.
Error in assignment.
Precision or scale out of range.
Datetime field overflow.
Division by zero.
Interval field overflow
Invalid character value for cast specification.
Integrity constraint violation.
Invalid cursor state.
Invalid transaction state.
Invalid SQL statement identifier.
Invalid authorization specification.
Invalid authorization specification; access to selected database is denied.
Invalid cursor name.
Syntax error in SQL dynamic statement.
Duplicate cursor name.
Attempt to initiate new SQL server operation with data pending.
Syntax error or access rule violation.
Operation aborted (server did not process cancel request).
Invalid table name; base table or view already exists.
Invalid table name; table or view not found.
Invalid index name; index already exists.
Invalid index name; index not found.
Invalid column name; column already exists.
Invalid column name; column not found.
General error.
General error: Ongoing transaction has been committed.
General error. Failed since resource governing policy is hit.
50 Error messages
S1094
S1095
S1096
S1097
S1098
S1099
S1100
S1101
S1009
S1010
S1012
S1015
S1090
S1091
S1092
S1093
S1102
S1103
S1105
S1000
S1000
S1001
S1002
S1003
S1004
S1005
S1006
S1007
S1008
Table 17 Error codes and error messages (continued)
Error codes
S1000
S1000
S1000
S1000
Error messages
The stored procedure required to complete this operation could not be found on the server (they were supplied with the ODBC/MX setup disk for the SQL Server driver).
Contact your service provider.
Unknown token received from SQL Server
Unable to load communication module. Driver has not been correctly installed.
Communication module is not valid. Driver has not been correctly installed.
Data type mismatch.
Program Error, Contact your service provider.
Memory allocation error.
Invalid column number.
Program type out of range.
SQL data type out of range.
Parameter number out of range.
Invalid conversion specified.
Row count not available from the data source.
Operation cancelled.
Invalid argument value.
Function sequence error
Invalid transaction operator code specified.
No cursor name available.
Invalid string or buffer length.
Descriptor type out of range.
Option type out of range.
Invalid parameter number.
Invalid scale value.
Function type out of range.
Information type out of range.
Column type out of range.
Scope type out of range.
Nullable type out of range.
Uniqueness option type out of range.
Accuracy option type out of range.
Table type out of range.
Direction option out of range.
Invalid parameter type or parameter type not supported.
51
Error codes
S1106
S1107
S1108
S1109
6006
6007
6008
6009
6010
S1C00
S1LD0
S1T00
6001
6002
6003
6004
6005
Table 17 Error codes and error messages (continued)
Error messages
Fetch type out of range.
Row value out of range.
Concurrency option out of range.
Invalid cursor position; no keyset defined.
Driver not capable.
No long data values pending.
Timeout expired.
INVALID DLL HANDLE.
CANNOT LOAD PROCADDRESS.
WRONG WINSOCK VERSION.
WRONG SIGNATURE.
WRONG VERSION.
ERROR FROM SERVER.
INCORRECT LENGTH.
MEMORY ALLOCATE.
WRONG IP ADDRESS.
Connection lost, invalid code path.
52 Error messages
A Sample ODBC application
Compiling and linking the sample application
HP-UX
Use the g++ compiler to compile the application with the header files that are shipped along with the driver: odbc]$ g++ -m64 -o < output object name > -I < location of the header files > \
< input file for compilation > -l mxodbc_ia64
Linux 32
Use the g++ compiler to compile the application with the header files that are shipped along with the driver: odbc]$ g++ -m32 -o < output object name > -I < location of the header files > \
< input file for compilation > -l mxodbc
Linux 64
Use the g++ compiler to compile the application with the header files that are shipped along nl with the driver: odbc]$ g++ -m64 -o < output object name > -I < location of the header files > \
< input file for compilation > -l mxodbc64
OSS
Use the c89 compiler to compile the application with the header files that are shipped along with the driver: oss> c89 -o < output object name> -I/usr/include/odbc/ \
-c < input file for compilation >
By default, the header files are located in the /usr/include/odbc directory.
Example for compiling a threaded application
HP-UX
The following is a sample compilation command: odbc]$ /usr/bin/g++ —m64 I < path for include files >
ThreadODBCTestAppl.c -o ThreadODBCTestAppl —l mxodbc_ia64
Linux 32
The following is a sample compilation command for a 32–bit application: odbc]$ /usr/bin/g++ -m32 -I < path for include files >
ThreadODBCTestAppl.c -o ThreadODBCTestAppl —l mxodbc
Linux 64
The following is a sample compilation command for a 64–bit application: odbc]$ /usr/bin/g++ -m64 -I < path for include files >
ThreadODBCTestAppl.c -o ThreadODBCTestAppl —l mxodbc64
OSS
The following is a sample compilation command for a 32–bit application:
OSS> c89 -g -Winspect -Wextensions -Ww -Woptimize=0 \
-Wsystype=oss -Wrefalign=8 -Wfieldalign=auto \
-Wallow_cplusplus_comments -Wcplusplus -Wversion3 \
-Wtarget=tns/e -DYOSEMITE -Wcall_shared \
-D__GNUC__ -DOSS_DRIVER -D_DEBUG -DNSK_PLATFORM \
-DTCL_MEM_DEBUG -D__TANDEM -Dset_fieldalign \
-D_TNS_R_TARGET -WIEEE_float -I/usr/include/odbc \
Compiling and linking the sample application 53
-c ThreadODBCTestAppl.c -o ThreadODBCTestAppl.o
The following is a sample compilation command for a 64–bit application:
OSS> c89 -g -Winspect -Wextensions -Ww -Woptimize=0 \
—W lp64 —Wsystype=oss -Wrefalign=8 -Wfieldalign=auto \
-Wallow_cplusplus_comments -Wcplusplus -Wversion3 \
-Wtarget=tns/e -DYOSEMITE -Wcall_shared —D_PUT_MODEL_\
-D__GNUC__ -DOSS_DRIVER -D_DEBUG -DNSK_PLATFORM \
-DTCL_MEM_DEBUG -D__TANDEM -Dset_fieldalign \
-D_TNS_R_TARGET -WIEEE_float -I/usr/include/odbc \
-c ThreadODBCTestAppl.c -o ThreadODBCTestAppl.o
NOTE: For C programming applications, add -Wallow_cplusplus_comments flag.
Use the eld linker to link the application with the driver (32–bit ZODBCDLL, 64–bit YODBCDLL).
By default, the driver is located in $SYSTEM.ZMXODBC directory.
Testing the sample
HP-UX and Linux
To run the sample test application, issue any of the following commands on the bash shell: odbc]$ ./<application name> <DS Name> odbc]$ ./<application name> –help
Considerations:
•
If the library is not present in the default location (/usr/lib or /usr/lib64 in 64 Bit
Linux), ensure that the location of the driver (libmxodbc.so, libmxodbc64.so in 64
Bit Linux) is set in the environment variable LD_LIBRARY_PATH (Linux 32 or Linux 64) or
SHLIB_PATH(HP-UX). To set the LD_LIBRARY_PATH variable, enter the following command: export LD_LIBRARY_PATH = < driver directory >
•
Ensure that the MXODSN file is present in the same location as that of the sample application.
If not, ensure that the default MXODSN file is present in /etc/hpodbc (Linux) or /etc/ mxodbc
(HP-UX), or set DSN_PATH to MXODSN location.
•
To enable tracing, set the TraceStart attribute in the MXODSN file to 1.
You must edit the MXODSN file to include your preferred DSN. Update all the mandatory fields for the DSN.
OSS
To run the sample test application, issue any of the following commands on the OSS shell:
OSS> ./<application name> <DS Name>
OSS> ./<application name> –help
Considerations:
•
Ensure that the ODBCDSN file is present in the same location as that of the sample application. If not, ensure that the ODBCDSN file is present in the default location,
$SYSTEM.SYSTEM or in the DSN_PATH.
•
To enable tracing, set the TraceStart attribute in the ODBCDSN file to 1.
You must edit the ODBCDSN file to include your preferred DSN. Update all the mandatory fields for the DSN.
Sample application code
/***************************************************************
*****
//
// @@@ START COPYRIGHT @@@
54 Sample ODBC application
//
// Copyright 2007
//
// HP CONFIDENTIAL: NEED TO KNOW ONLY
//
// Copyright Hewlett-Packard Development Company, L.P.
// Protected as an unpublished work.
//
// The computer program listings, specifications and
// documentation herein are the property of Hewlett-Packard
// Development Company, L.P., or a third party supplier and
// shall not be reproduced, copied, disclosed, or used in whole
// or in part for any reason without the prior express written
// permission of Hewlett-Packard
// Development Company, L.P.
//
// @@@ END COPYRIGHT @@@
***************************************************************/
/***************************************************************
@@@@ ODBC TEST APPLICATION @@@
================================================================
This application utilizes ::
- Multiple connections
- Gives information about DBMS NAME
- ODBC API's
- Uses insertion through parameter marker,
- Setting the transaction isolation level as serializable and fetches the data.
****************************************************************
******/
#include <stdio.h>
#include <stdlib.h>
#include <sqlext.h>
#include <string.h>
#define UnSignCharCast unsigned char *
#define TRUE 1 typedef struct
{
SDWORD pfNativeError[1];
SWORD pcbErrorMsg[1];
SWORD cbErrorMsgMax;
UCHAR *szErrorMsg;
UCHAR *szSqlState;
} ERR_INFO;
RETCODE odbc_Error(SQLHENV hEnv, SQLHDBC hDbc, SQLHSTMT hStmt);
RETCODE odbc_Error(
SQLHENV hEnv,
SQLHDBC hDbc,
SQLHSTMT hStmt
)
{
char *szBuf;
int pt_ch ='.' ;
int brac_ch =']' ;
ERR_INFO *Err;
RETCODE st = 0;
Err = (ERR_INFO *)malloc (sizeof(ERR_INFO));
Err->szErrorMsg = (UnSignCharCast )malloc(200);
Err->szSqlState = (UnSignCharCast )malloc(50);
szBuf = (char *)malloc(600);
memset (Err->szErrorMsg,'\0',200);
memset (Err->szSqlState,'\0',50);
Testing the sample 55
memset (szBuf,'\0',600);
if (hStmt)
st = SQLGetDiagRec(SQL_HANDLE_STMT,hStmt,1,Err->szSqlState,
Err->pfNativeError, Err->szErrorMsg,150,Err->pcbErrorMsg);
else if (hDbc)
st = SQLGetDiagRec(SQL_HANDLE_DBC,hDbc,1,Err->szSqlState,
Err->pfNativeError, Err->szErrorMsg,150,Err->pcbErrorMsg);
else if (hEnv)
st = SQLGetDiagRec(SQL_HANDLE_ENV,hEnv,1,Err->szSqlState,
Err->pfNativeError, Err->szErrorMsg,150,Err->pcbErrorMsg);
if ((st == SQL_SUCCESS) || (st == SQL_SUCCESS_WITH_INFO))
{
sprintf(szBuf," %s - [%s]\n", (char *)Err->szErrorMsg,
Err->szSqlState);
printf("%s \n",szBuf);
}
free(Err->szErrorMsg);
free(Err->szSqlState);
free(Err);
free(szBuf);
return SQL_SUCCESS;
} int main(int argc, char *argv[])
{
RETCODE st = 0;
SQLHENV henv = (SQLHENV) NULL;
SQLHDBC hdbc = (SQLHDBC) NULL;
SQLHDBC hdbc1 = (SQLHDBC) NULL;
SQLHDBC hdbc2 = (SQLHDBC) NULL;
SQLHSTMT hstmt = (SQLHSTMT) NULL;
SQLHSTMT hstmt1 = (SQLHSTMT) NULL;
CHAR CreateTable[100] = {'\0'};
CHAR InsertTable[100] = {'\0'};
CHAR SelectTable[100] = {'\0'};
int value;
SQLINTEGER ValInd;
SQLINTEGER RowCount = 0;
SQLINTEGER val;
SDWORD pcbValue = 0;
SQLCHAR infoValueBuf[100] = {'\0'};
SQLCHAR*infoValuePtr=0;
SQLSMALLINT StringLengthPtr = NULL;
char Password[40]="\0";
char UserID[40]="\0";
char *serverName="TDM_Default_DataSource";
short value1=10;
short value2=20;
bool defaultDS=false;
printf("\n\tPURPOSE :: TO TEST ODBC API'S ON ODBC
DRIVER\n\n");
if(argc>1)
{
if(!strcmp(argv[1], "-help"))
{
printf("USAGE: odbcdemo <DataSourceName> \n");
printf("Eg: odbcdemo DEMO\n");
printf("Note: Default Data Source will be used in case no DS
specified!\n");
return 0;
}
serverName = argv[1];
}
printf("User Name: ");
scanf("%s", UserID);
printf("Password : ");
56 Sample ODBC application
scanf("%s", Password);
strcpy(CreateTable,"create table GGTest(c1 int)");
sprintf(InsertTable, "%s %d %s", "insert into GGTest(c1) values
(", value1, ");");
strcpy(SelectTable,"select * from GGTest" );
printf("\n\tUsing Data Source : %s \n\n", serverName);
if (!strncmp(serverName, "TDM_Default_DataSource",
strlen(serverName)))
defaultDS = true;
st = SQLAllocEnv(&henv);
if (henv == NULL)
{
printf("Error in allocating Env Handle!\n");
odbc_Error(SQL_NULL_HENV,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(void*)SQL_OV_ODBC3, 0);
if (st != SQL_SUCCESS)
{
printf("Error in SQLSetEnvAttr :: %d\n", st);
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLAllocConnect(henv, &hdbc);
if (hdbc == NULL)
{
printf("Error in allocating connection Handle 1!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLAllocConnect(henv, &hdbc1);
if (hdbc1 == NULL)
{
printf("Error in allocating connection Handle 2!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLAllocConnect(henv, &hdbc2);
if (hdbc2 == NULL)
{
printf("Error in allocating connection Handle 3!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st =
SQLConnect(hdbc,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,SQ
L_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 1\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
exit(1);
}
else
printf("Connection 1 Successful\n");
st = SQLSetConnectAttr(hdbc,
SQL_ATTR_TXN_ISOLATION,(SQLPOINTER)8,0);
if (st != SQL_SUCCESS)
{
printf("Error in SQLSetConnectAttr()\n");
odbc_Error(henv,hdbc,hstmt);
}
st =
SQLConnect(hdbc1,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,
SQL_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 2\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
Testing the sample 57
}
else
printf("Connection 2 Successful\n");
st =
SQLConnect(hdbc2,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,
SQL_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 3\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
}
else
printf("Connection 3 Successful\n");
st = SQLGetInfo(hdbc,SQL_DBMS_NAME, infoValueBuf,
sizeof(infoValueBuf), &StringLengthPtr);
infoValuePtr = infoValueBuf;
if (st != SQL_SUCCESS)
{
printf("Error in SQLGetInfo\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("\n\tDBMS NAME : %s\n\n", infoValuePtr);
printf("\n\tUsing Connection 1\n\n");
st = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHDBC)hdbc, &hstmt);
if (hstmt == NULL)
{
printf("Error in allocating Statement Handle\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
}
st = SQLExecDirect(hstmt,(SQLCHAR *)
CreateTable,strlen(CreateTable));
if ( st != SQL_SUCCESS)
{
printf("Error in Create Table: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Create table GGTest Successful\n");
st = SQLExecDirect(hstmt, (SQLCHAR *)
InsertTable,strlen(InsertTable));
if (st != SQL_SUCCESS)
{
printf("Error in Insert Table 1: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Insert Successful: %d\n", value1);
memset(InsertTable, '\0', sizeof(InsertTable));
sprintf(InsertTable, "%s %d %s", "insert into GGTest(c1) values
(", value2, ");");
st = SQLExecDirect(hstmt,(SQLCHAR*)InsertTable,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Insert Table 2: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Insert Successful: %d\n", value2);
st = SQLRowCount(hstmt,&RowCount);
if (st != SQL_SUCCESS)
{
printf("Error in SQLRowCount()\n");
odbc_Error(henv,hdbc,hstmt);
}
58 Sample ODBC application
else
printf("Row(s) affected %d\n", RowCount);
st = SQLExecDirect(hstmt,(SQLCHAR *)
SelectTable,strlen(SelectTable));
if (st != SQL_SUCCESS)
{
printf("Error in Select Table: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
st = SQLBindCol(hstmt, 1, SQL_C_SLONG, &value, 0, &ValInd);
if (st != SQL_SUCCESS)
{
printf("Error in SQLBindCol\n");
odbc_Error(henv,hdbc,hstmt);
}
while(TRUE)
{
if ((st = SQLFetch(hstmt)) == SQL_NO_DATA_FOUND)
break;
if ( (st != SQL_SUCCESS) && (st != SQL_SUCCESS_WITH_INFO) )
{
printf("Error in SQLFetch!!! Returned Status: %d\n", st);
break;
}
if (ValInd == SQL_NULL_DATA)
{
printf("No Data fetched!\n");
break;
}
else
{
printf("c1 :: %d\n", value);
}
}
// ***************** Done with connection 1 ********************
printf("\n\tUsing Connection 2\n\n");
st = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHDBC)hdbc1, &hstmt1);
if (hstmt1 == NULL)
{
printf("Error in allocating statement handle\n");
odbc_Error(SQL_NULL_HENV,SQL_NULL_HDBC,hstmt);
}
st = SQLPrepare(hstmt1,(SQLCHAR *)"insert into GGTest(c1)
values(?)",SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in SQLPrepare\n");
odbc_Error(henv,hdbc1,hstmt1);
}
st =
SQLBindParameter(hstmt1,1,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER
,0,0,&val, 0, &pcbValue);
val = 50;
if(st != SQL_SUCCESS)
{
printf("Error in SQLBindParameter : %d\n", st);
odbc_Error(henv,hdbc1,hstmt1);
}
st = SQLExecute(hstmt1);
if(st != SQL_SUCCESS)
{
printf("Error in SQLExecute : %d\n", st);
odbc_Error(henv,hdbc1,hstmt1);
}
else
Testing the sample 59
printf("Insert Successful : %d\n", val);
strcpy(SelectTable,"select * from GGTest" );
st = SQLExecDirect(hstmt1,(SQLCHAR *)
SelectTable,strlen(SelectTable));
if (st != SQL_SUCCESS)
{
printf("Error in select table : GGTest\n");
odbc_Error(henv,hdbc1,hstmt1);
}
st = SQLBindCol(hstmt1, 1, SQL_C_SLONG, &value, 0, &ValInd);
if(st != SQL_SUCCESS)
{
printf("Error in SQLBindCol\n");
odbc_Error(henv,hdbc1,hstmt1);
}
while(TRUE)
{
if ((st = SQLFetch(hstmt1)) == SQL_NO_DATA_FOUND)
break;
if ( (st != SQL_SUCCESS) && (st != SQL_SUCCESS_WITH_INFO) )
{
printf("Error in SQLFetch!!! Returned Status: %d\n", st);
break;
}
if (ValInd == SQL_NULL_DATA)
{
printf("No Data Fetched!\n");
break;
}
else
{
printf("c1 :: %d\n", value);
}
}
st = SQLExecDirect(hstmt1,(SQLCHAR*)"drop table
GGTest",SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in drop table : GGTest\n");
odbc_Error(henv,hdbc1,hstmt1);
}
else
printf("\nTable GGTEST dropped!\n");
st = SQLEndTran(SQL_HANDLE_DBC,(SQLHANDLE)hdbc,SQL_ROLLBACK);
if (hstmt)
SQLFreeStmt(hstmt,SQL_CLOSE);
if (hstmt1)
SQLFreeStmt(hstmt1,SQL_CLOSE);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLDisconnect(hdbc1);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc1);
SQLDisconnect(hdbc2);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc2);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
return 0;
}
60 Sample ODBC application
Glossary
Driver Manager
The ODBC component that manages access to Database Management System (DBMS) drivers for ODBC applications. The driver manager loads and unloads drivers and passes the calls for ODBC functions to the correct driver. The HP-UX and Linux drivers support both the Nonstop driver manager and the unixODBC driver manager.
Open Database Connectivity (ODBC)
An interface specification for an API that defines a standard set of routines that an
ODBC application can use to access data in a database.
ODBC/MX
The ODBC components and products to support the ODBC functionality for the
SQL/MX database.
61
Index
A
AutoCommit,
B
BIGINT data type,
BINARY data type,
BIT data type,
C
Catalog and schema consideration,
CHAR data type,
Client data source configuring,
D
Data sources managing,
data sources configuring,
managing,
data types unsigned,
data types supported,
DATE data type,
DATETIME,
DECIMAL data type,
default data source
TDM_Default_DataSource,
Documents, related information,
DOUBLE PRECISION data type,
Driver considerations,
E error codes,
F
FLOAT data type,
I
INTEGER data type,
INTERVAL MONTH data type,
INTERVAL YEAR data type,
IPV6,
L
Linux ODBC Client Driver overview,
LONG VARBINARY data type,
LONGVARCHAR data type,
N
NUMERIC data type,
62 Index
R
REAL data type,
S
Server data source configuring,
Server-side components,
SMALLINT data type,
SQL Datetime Retrieval,
SQL Interval Behaviour,
SQL_QUERY_TIMEOUT
SQLSetStmtOption,
SQLBindParameter consideration,
SQLCancel consideration,
SQLPrimaryKeys consideration,
SQLPutData consideration,
SQLSpecialColumns consideration,
SQLStatistics consideration,
SQLTables
SQL_ALL_CATALOGS,
SQL_ALL_SCHEMAS,
SQL_ALL_TABLE_TYPES,
T
TIME data type,
TIMESTAMP data type,
TINYINT data type,
tracing data sources,
U unixODBC driver manager,
Unsupported ODBC APIs,
Unsupported ODBC data types,
V
VARBINARY data type,
VARCHAR data type,
advertisement
Key Features
- Allows applications to access data from an SQL/MX database.
- Implements ODBC 3.5 set of APIs.
- Supports different platforms including Linux, HP-UX, and Windows.
- Provides support for secure ODBC connection using NonStop SSL.
- Allows for tracing of driver activity for troubleshooting.
Frequently Answers and Questions
What platforms are supported by the ODBC/MX client drivers?
What version of ODBC is supported by the drivers?
What is the purpose of the ODBC/MX client drivers?
How can I configure secure ODBC connections using NonStop SSL?
Related manuals
advertisement
Table of contents
- 5 Intended audience
- 5 Document organization
- 5 New and changed information in this edition
- 5 Notation conventions
- 5 General syntax notation
- 7 Related Documentation
- 7 NonStop SQL/MX customer library
- 9 Publishing history
- 9 HP encourages your comments
- 10 Architecture
- 12 Client components
- 12 Server components
- 12 Driver managers
- 13 Data sources
- 13 Client data source configuration
- 13 Server data source configuration
- 13 Default data source
- 14 Tracing
- 14 Object naming and mapping
- 14 ANSI name type
- 14 ANSI names for SQL/MX objects
- 14 ANSI alias names for SQL/MP objects
- 14 Unsupported ODBC APIs
- 15 Unsupported ODBC data types
- 15 Considerations and limitations
- 17 Installation requirements
- 17 Installation procedures
- 21 Verifying the installation
- 22 Uninstalling the driver
- 24 Configuring a client data source
- 26 Configuring the drivers for IPv6
- 26 Configuring a secure ODBC connection using NonStop SSL
- 26 Installing a NonStop SSL Server process for ODBC/MX
- 27 Installing and configuring the Remote Proxy Client
- 28 Configuring a client data source for NonStop SSL
- 29 DataSource configuration in Windows driver
- 30 MXODSN and ODBCDSN file formats
- 33 Managing data sources
- 34 Managing transactions
- 34 Setting AutoCommit
- 34 Windows driver
- 34 Unix drivers
- 35 Using connection string without DSN
- 35 Tracing
- 37 Considerations
- 38 ODBC data types
- 39 Unsigned data types
- 40 Partial DATE or TIME values
- 41 Microsoft escape clauses
- 41 Stored Procedures
- 41 Transaction and cursor behavior
- 42 Timestamp values with fraction
- 46 SQL Interval Behaviour property
- 48 SQL Datetime Retrieval property
- 53 Compiling and linking the sample application
- 53 Example for compiling a threaded application
- 54 Testing the sample
- 54 Sample application code