DataStage Universe Basic SQL Client Interface Guide
DataStage Universe Basic SQL Client Interface Guide
fm
March 12, 2010 3:41 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta
UniVerse
UNV-103-BCI-1
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\BCITITL.fm
March 12, 2010 3:41 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Notices
Edition
Publication date: February 2009
Book number: UNV-103-BCI-1
Product version: UniVerse 10.3
Copyright
© Rocket Software, Inc. 1985-2009. All Rights Reserved.
Trademarks
The following trademarks appear in this publication:
Java™ and all Java-based trademarks and logos Sun Microsystems, Inc.
License agreement
This software and the associated documentation are proprietary and confidential to
Rocket Software, Inc., are furnished under license, and may be used and copied only
in accordance with the terms of such license and with the inclusion of the copyright
notice. This software and any copies thereof may not be provided or otherwise made
available to any other person. No title to or ownership of the software and associated
documentation is hereby transferred. Any unauthorized use or reproduction of this
software or documentation may be subject to civil or criminal liability. The information
in the software and documentation is subject to change and should not be construed
as a commitment by Rocket Software, Inc.
Restricted rights notice for license to the U.S. Government: Use, reproduction, or
disclosure is subject to restrictions as stated in the “Rights in Technical Data-
General” clause (alternate III), in FAR section 52.222-14. All title and ownership in
this computer software remain with Rocket Software, Inc.
Note
This product may contain encryption technology. Many countries prohibit or restrict
the use, import, or export of encryption technologies, and current use, import, and
export regulations should be followed when exporting this product.
Please be aware: Any images or indications reflecting ownership or branding of the
product(s) documented herein may or may not reflect the current legal ownership of
the intellectual property rights associated with such product(s). All right and title to
the product(s) documented herein belong solely to Rocket Software, Inc. and its
subsidiaries, notwithstanding any notices (including screen captures) or any other
indications to the contrary.
Contact information
Rocket Software
275 Grove Street Suite 3-410
Newton, MA 02466-2272
USA
Tel: (617) 614-4321 Fax: (617) 630-7100
Web Site: www.rocketsoftware.com
Table of Contents
Preface
Organization of This Guide . . . . . . . . . . . . . . . . ii
Documentation Conventions. . . . . . . . . . . . . . . . iii
UniVerse Documentation. . . . . . . . . . . . . . . . . v
Related Documentation . . . . . . . . . . . . . . . . . vii
API Documentation . . . . . . . . . . . . . . . . . . viii
Chapter 1 Introduction
UniVerse Data Sources . . . . . . . . . . . . . . . . 1-2
ODBC Data Sources . . . . . . . . . . . . . . . . 1-2
Additional BASIC Functions . . . . . . . . . . . . . . . 1-4
The CONNECT Command . . . . . . . . . . . . . . . . 1-5
System Requirements . . . . . . . . . . . . . . . . . . 1-6
Administering the RPC on UniVerse Servers . . . . . . . . . . 1-7
ODBC Dynamic Link Libraries. . . . . . . . . . . . . . . 1-8
Table of Contents v
Print Result Set . . . . . . . . . . . . . . . . . . 5-5
Affected-Row Count . . . . . . . . . . . . . . . . 5-6
Processing Errors from UniVerse Procedures . . . . . . . . . . 5-7
Calling and Executing ODBC Procedures . . . . . . . . . . . 5-8
Appendix E
Much of the information in this book originally appeared in uV/SQL Client Option
Guide.
i
Organization of This Guide
This guide contains the following:
Chapter 2, “Getting Started,” describes how to configure your system to use the SQL
Client Interface.
Chapter 3, “Using the CONNECT Command,” describes how to use the CONNECT
command.
Chapter 4, “Using the SQL Client Interface,” tells how to use the SQL Client
Interface to communicate with servers.
Chapter 5, “Calling and Executing Procedures,” describes how to call and execute
procedures stored on a UniVerse or ODBC data source.
Chapter 7, “SQL Client Interface Functions,” describes the SQL Client Interface
functions.
Appendix A, “Data Conversion,” describes how the SQL Client Interface converts
data between the client system and various server DBMSs.
Appendix C, “Error Codes,” describes error codes and messages issued by the SQL
Client Interface.
Appendix E, “The ODBC.H File,” lists the contents of the ODBC.H file, which
defines the values of column attributes.
Convention Usage
Courier Bold In examples, courier bold indicates characters that the user types
or keys the user presses (for example, <Return>).
itemA | itemB A vertical bar separating items indicates that you can choose
only one item. Do not type the vertical bar.
... Three periods indicate that more of the same type of item can
optionally follow.
iii
All punctuation marks included in the syntax—for example, commas,
parentheses, or quotation marks—are required unless otherwise indicated.
Syntax lines that do not fit on one line in this manual are continued on
subsequent lines. The continuation lines are indented. When entering
syntax, type the entire syntax entry, including the continuation lines, on the
same input line.
UniVerse New Features Version 10.3: Describes enhancements and changes made
in the UniVerse 10.3 release for all UniVerse products.
UniVerse BASIC SQL Client Interface Guide: Describes how to use the UniVerse
BASIC SQL Client Interface (BCI), an interface to UniVerse and non-UniVerse
databases from UniVerse BASIC. The BASIC SQL Client Interface uses ODBC-like
function calls to execute SQL statements on local or remote database servers such as
UniVerse, INFORMIX, SYBASE, or DB2. This book is for experienced SQL
programmers.
Using UniAdmin: Describes the UniAdmin tool, which enables you to configure
UniVerse, configure and manage servers and databases, and monitor UniVerse
performance and locks.
v
UniVerse System Description: Provides detailed and advanced information about
UniVerse features and capabilities for experienced users. This book describes how to
use UniVerse commands, work in a UniVerse environment, create a UniVerse
database, and maintain UniVerse files.
UniVerse User Reference: Contains reference pages for all UniVerse commands,
keywords, and user records, allowing experienced users to refer to syntax details
quickly.
Guide to RetrieVe: Describes RetrieVe, the UniVerse query language that lets users
select, sort, process, and display data in UniVerse files. This book is for users who
are familiar with UniVerse.
Guide to the UniVerse Editor: Describes in detail how to use the Editor, allowing
users to modify UniVerse files or programs. This book also includes reference pages
for all UniVerse Editor commands.
UniVerse NLS Guide: Describes how to use and manage UniVerse’s National
Language Support (NLS). This book is for users, programmers, and administrators.
UniVerse SQL User Guide: Describes how to use SQL functionality in UniVerse
applications. This book is for application developers who are familiar with UniVerse.
UniVerse SQL Reference: Contains reference pages for all SQL statements and
keywords, allowing experienced SQL users to refer to syntax details quickly. It
includes the complete UniVerse SQL grammar in Backus Naur Form (BNF).
UniVerse GCI Guide: Describes how to use the General Calling Interface (GCI) to
call subroutines written in C, C++, or FORTRAN from BASIC programs. This book
is for experienced programmers who are familiar with UniVerse.
UniVerse ODBC Guide: Describes how to install and configure a UniVerse ODBC
server on a UniVerse host system. It also describes how to install, configure, and use
UniVerse ODBC drivers on client systems. This book is for experienced UniVerse
developers who are familiar with SQL and ODBC.
IBM JDBC Driver for UniData and UniVerse: Describes UniJDBC, an interface to
UniData and UniVerse databases from JDBC applications. This book is for
experienced programmers and application developers who are familiar with UniData
and UniVerse, Java, JDBC, and who want to write JDBC applications that access
these databases.
UniVerse Guide for Pick Users: Describes UniVerse for new UniVerse users familiar
with Pick-based systems.
vii
API Documentation
The following books document application programming interfaces (APIs) used for
developing client applications that connect to UniVerse and UniData servers.
Administrative Supplement for APIs: Introduces IBM’s seven common APIs for
UniData and UniVerse, and provides important information that developers using
any of the common APIs will need. It includes information about the UniRPC, the
UCI Config Editor, the ud_database file, and device licensing.
UCI Developer’s Guide: Describes how to use UCI (Uni Call Interface), an interface
to UniVerse and UniData databases from C-based client programs. UCI uses ODBC-
like function calls to execute SQL statements on local or remote UniVerse and
UniData servers. This book is for experienced SQL programmers.
IBM JDBC Driver for UniData and UniVerse: Describes UniJDBC, an interface to
UniVerse and UniData databases from JDBC applications. This book is for
experienced programmers and application developers who are familiar with UniData
and UniVerse, Java, JDBC, and who want to write JDBC applications that access
these databases.
InterCall Developer’s Guide: Describes how to use the InterCall API to access data
on UniVerse and UniData systems from external programs. This book is for
experienced programmers who are familiar with UniVerse or UniData.
UniObjects for Java Developer’s Guide: Describes UniObjects for Java, an interface
to UniVerse and UniData systems from Java. This book is for experienced
programmers and application developers who are familiar with UniVerse or UniData,
and with Java, and who want to write Java programs that access these databases.
ix
Chapter
Introduction
1
UniVerse Data Sources . . . . . . . . . . . . . . . 1-2
ODBC Data Sources . . . . . . . . . . . . . . . . 1-2
Additional BASIC Functions . . . . . . . . . . . . . . . 1-4
The CONNECT Command . . . . . . . . . . . . . . . 1-5
System Requirements . . . . . . . . . . . . . . . . . 1-6
Administering the RPC on UniVerse Servers . . . . . . . . . . 1-7
ODBC Dynamic Link Libraries . . . . . . . . . . . . . . 1-8
You use the SQL Client Interface to connect to one or more data sources.
As of Release 9.4.1, UniVerse servers can run with NLS (National Language
Support) enabled. NLS provides extensive support for many singlebyte and
multibyte character sets and country-specific locale settings. NLS lets client
application programs store and retrieve data in a UniVerse data source using the
character sets and locale settings most appropriate for the client application and
operating system. NLS is fully documented in the UniVerse NLS Guide.
Once connected to any data source, the SQL Client Interface lets you read data from
and write data to the data source. Your application program can access the
capabilities of the server DBMS, as shown in the following example.
1-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch1
3/12/10
UniVerse UniVerse
RPC
BASIC local services DBMS
application UniVerse
program account
(localuv) ODBC Server O/S
SQL Client driver for
Interface INFORMIX INFORMIX
DBMS
ODBC
driver for
ODBC driver DB2
manager
Server O/S
ODBC
driver for DB2
SYBASE DBMS
Server O/S
SYBASE
DBMS
The SQL Client Interface also includes the CONNECT command, which lets users
access data sources interactively. For detailed information about the CONNECT
command, see Chapter 3, “Using the CONNECT Command.”
The SQL Client Interface is based on the core-level definition of the Microsoft Open
Database Connectivity (ODBC) interface. The ODBC interface lets you write
programs that can operate across a wide range of data sources. With the SQL Client
Interface, application developers have access to the full range of capabilities offered
by the server DBMS. For complete information about the ODBC interface, see
Microsoft ODBC 2.0 Programmer’s Reference and SDK Guide.
The I/O operations in the SQL Client Interface differ from normal BASIC I/O. The
SQL Client Interface does not use the BASIC file operations OPEN, READ, WRITE,
and CLOSE.
1-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch1
3/12/10
System Requirements
To use the SQL Client Interface to access the local UniVerse database, you need
Release 9.6 or later of UniVerse.
To use the SQL Client Interface to access a remote UniVerse database, you need the
following:
TCP/IP hardware and software installed on both client and server systems
Release 9.6 or later of UniVerse on the client system
Release 9.6 or later of UniVerse on the server system
The UniRPC daemon (unirpcd) running on a UNIX server
The UniRPC service (unirpc) running on a Windows server
To use the SQL Client Interface to access an ODBC database, you need the
following:
TCP/IP hardware and software installed on both client and server systems
At least one DBMS installed on a server system
ODBC driver manager and ODBC driver for the data source, installed on the
client system
Release 9.6 or later of UniVerse installed on the client system
1-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch1
3/12/10
On Windows platforms, the RPC service unirpc receives connection requests and
starts the server processes. A helper thread runs as part of the uvserver process on
Windows platforms.
Before any client can connect to the UniVerse server, the system administrator of the
server must ensure that the RPC daemon or service is running and that the
unirpcservices file, which defines the RPC services available on the server, contains
an entry (uvserver) for the uvsrvd daemon. Once the RPC daemon or service is
started, it automatically restarts whenever you reboot UniVerse.
Note: The RPC must be configured and running even if the client and server systems
are on the same machine, unless you make a direct connection to the local UniVerse
server using the host name localhost or the loopback IP address 127.0.0.1.
See Administering UniVerse for information about executing the following tasks:
If for any reason the symbolic link is broken, or if the system administrator moves
the shared libraries to another directory, the relink.uvlibs shell script must be used to
relink them. The relink.uvlibs script resides in $uvhome/bin. To relink the shared
libraries, use the following syntax:
relink.uvlibs pathname
pathname is the full path of the directory containing the shared libraries. For
example:
% relink.uvlibs $uvhome/uvdlls
Before using the SQL Client Interface to connect to an ODBC data source, the
administrator must reestablish the link to uvdlls in order to use the ODBC driver
manager. To do this, complete the following steps:
1-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch1
3/12/10
The library directory containing the ODBC driver’s DDL is stored in an environment
variable, which may not be the same name on all systems. For example, the
environment variable is called LD_LIBRARY_PATH on Solaris systems,
SHLIB_PATH on HP systems, and so on. If this environment variable is not properly
set, running SQL Client Interface programs may produce errors such as the
following:
Getting Started
2
Configuring the BASIC SQL Client Interface . . . . . . . . . . 2-3
Changing the Size of the Server’s Result-Set Buffer . . . . . . 2-4
Location of the Configuration File . . . . . . . . . . . . 2-4
Format of the Configuration File . . . . . . . . . . . . 2-5
Client Configuration for NLS-Enabled UniVerse Servers . . . . . 2-5
Creating and Modifying Data Source Definitions . . . . . . . 2-6
Using the UniVerse System Administration Menus. . . . . . . 2-10
Maintaining the Configuration File. . . . . . . . . . . . 2-11
Using the SQL Client Interface . . . . . . . . . . . . . . 2-18
Running the Demonstration Program . . . . . . . . . . . . 2-19
Create a Schema . . . . . . . . . . . . . . . . . 2-19
Run the Program . . . . . . . . . . . . . . . . . 2-20
2-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
The SQL Client Interface defines a data source by means of a data source
specification. A data source specification contains all information needed to let an
application connect to and interact with a data source. Data source specifications are
stored in the configuration file uvodbc.config.
When you install UniVerse, the configuration file contains one specification
(localuv) for the local UniVerse server. The uvodbc.config file should contain at least
one data source specification for each UniVerse data source to which you want to
connect.
ODBC data sources need not be specified in uvodbc.config. However, if you want to
use the CONNECT command to connect to an ODBC data source, you must specify
the data source in uvodbc.config.
You can specify several different data source specifications (with different names) for
the same data source. Each specification must include the following:
Data source name, which the SQL Client Interface uses to reference the data
source. You use this name with the CONNECT command or the BASIC
SQLConnect call to specify the data source you are connecting to.
DBMS type, which defines the type of data source (UNIVERSE or ODBC).
The DBMS type determines what internal parameters the SQL Client
Interface needs in order to exchange data with the data source.
UniVerse data source specifications also require the following three elements, which
are not required for ODBC data sources:
Network host name or IP address of the machine running the UniVerse data
source to which you want to connect. For a direct connection to the local
UniVerse server, the host name is either localhost or the loopback IP address
127.0.0.1.
In addition to the required items, a data source specification can include extended
parameters that control data precision, transaction management, NLS locale
information, and so on. Extended parameters tailor the operation of a particular data
source or of all data sources.
Note: The ODBC data source name in the uvodbc.config file must match the data
source name specified in the initialization file (odbc.ini) or registry of the ODBC data
source.
MAXFETCHBUFF specifies the size of the buffer the server uses to hold data rows
before sending them to the client. MAXFETCHCOLS specifies the number of
column values the server can put in the buffer before sending them to the client. For
example, if MAXFETCHCOLS is set to 100 column values and you do a SELECT
of 40 columns, no more than two rows can be sent in any buffer, because the total
number of column values in two rows is 80. Three rows would contain 120 column
values, which exceeds the value of MAXFETCHCOLS.
2-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
<uv8dg>
DBMSTYPE = UNIVERSE
NETWORK = TCP/IP
SERVICE = uvserver
HOST = dg8500
<ora>
DBMSTYPE = ODBC
<syb>
DBMSTYPE = ODBC
If you need to specify particular server locale information, change the uvodbc.config
file to contain this information either for each data source or for all UniVerse server
connections. NLS users should note that the uvodbc.config file entries are in ASCII
format. When you specify NLS and locale parameters in the uvodbc.config file, you
do not need to make changes to your programs to let client programs work with an
NLS-enabled server.
NLSLCTIME
NLSLCNUMERIC
NLSLCMONETARY
NLSLCCTYPE
NLSLCCOLLATE
Use the NLSLOCALE parameter to specify all of a locale’s components. Use the
NLSLCALL parameter to specify a slash-separated list of locales. These locales
specify the five locale categories in the order listed above.
This sets all components of the locale for this connection to those indicated by the
entry in the NLS.LC.ALL table with ID = NL-DUTCH, except for the
LCMONETARY entry, which is loaded from the NLS.LC.MONETARY table for the
DEFAULT entry.
If more than one entry is found in the NLSLCALL entry, all entries must be
nonempty and must represent valid entries in the appropriate NLS.LC.category table.
2-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
On UNIX systems you can use the UniVerse System Administration menus to edit
the configuration file. You must be a UniVerse Administrator to use the System
Administration menus.
Using UniAdmin
Creating the Configuration File
Data source administration lets you view and change the current set of defined
BASIC SQL Client Interface (BCI) data sources.
To administer UniVerse data sources, choose Data Sources from the UniAdmin main
window. The UniVerse Data Sources window appears, as shown in the following
example:
Create a new data source Click New… Display the Account Details
dialog box.
Delete an existing data source Select the data source, Prompt you for confirmation,
then click Delete… and delete the data source if
you click Yes.
View information about a data Select the data source, Display the Account Details
source then click Detail… dialog box.
Dismiss the Data Source Admin Close Return to the UniAdmin main
window window.
Get information about data source Help Display the online help.
administration
Data Source Administration Operations
2-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
Data Source The name you want to assign to the new data source.
Network Type Click TCP/IP or LAN Pipes to specify the communication transport to
use to communicate with the data source. You can use LAN pipes only
with Windows servers.
DBMS Type Name of the database management system on the server. Currently, the
only choices are UNIVERSE and ODBC.
Service name UniVerse server name. Currently you cannot change this field.
Hostname Name or IP address of the server on which the data source resides.
3. Click OK to add the new data source or click Cancel to return to the
UniVerse Data Sources window without making any changes.
To display the Sql Client Administration menu, choose Package from the System
Administration main menu, then choose Sql client administration. The submenu
shown in the following example appears.
The first time you choose an option from the Sql client administration menu,
UniVerse prompts you to enter the full path of the configuration file. The default is
uvodbc.config in the current directory.
2-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
Option Description
data Source specifications Defines new data sources and change information
about existing data sources.
Dbms type extended Defines additional parameters for all data sources
parameters of a particular type (UNIVERSE or ODBC).
SQL client administration Options
When you choose an option, a data entry screen appears. The menu bar at the top of
the screen provides three pull-down menus. Press F10 or Ctrl-T to move the cursor
to the menu bar.
The File and Help menus have the same options on all Sql client administration
screens.
Option Description
Refresh Discards the currently displayed values and retrieves the most recently saved
data.
Exit Returns to the previous pull-down menu. If the data source name field is not
empty, the system asks whether you want to save your changes to the
configuration file.
File Menu Options
The Help menu provides help about the Application, the Keys, and the current
Version number. Action menu options are explained in the following sections.
At the Data Source Name prompt, enter the name of a data source. When you enter
the name of a new data source, you can define the data source by entering values in
each field. When you enter the name of an existing data source, the details of that
source are displayed and you can change the values in any field. Press F4 or enter *
(asterisk) to list all currently defined data sources. You can then enter the name of a
data source by choosing it.
In the “DBMS Type” field, press F4 or enter * (asterisk) to list the valid DBMS types.
The SQL Client Interface supports these DBMS types:
UNIVERSE
ODBC
The Network Type field is relevant only for UniVerse data sources. It can be TCP/IP
or LAN. Use LAN only for two or more Windows platforms connected to each other.
The Service Name field is relevant only for UniVerse data sources. The service name
of the UniVerse server is uvserver.
2-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
The Host Name/Address field is relevant only for UniVerse data sources. If you
specify a network host name for a UniVerse data source, the host name must be in the
hosts file (or equivalent file if you use another network administration mechanism
such as Yellow Pages) on the client system. You can specify the host name or an IP
address for the local UniVerse server as well as for remote data sources. For direct
connections to the current account on the local UniVerse server, use the host name
localhost or the TCP/IP loopback address 127.0.0.1.
When you press ENTER at the end of the Host Name/Address field, UniVerse
prompts to change data in any field.
If you choose Yes, use the cursor keys to move to the fields you want to change, enter
the new values, then move to the Host Name/Address field and press ENTER.
When you choose No, UniVerse prompts to save your data. Choose Yes to save your
data in the configuration file.
Option Description
Rename Prompts you to enter a data source name and changes the current data source
name to the name you enter.
Copy Prompts you to enter a data source name and copies the currently displayed
data to the new data source specification. Extended data source parameters
are not copied.
Action Menu Options
At the Data Source prompt, enter the name of a data source. Press F4 or enter
* (asterisk) to list data sources currently defined in the configuration file.
At the Parameter prompt, enter ? (question mark) to list possible parameters. Press
F4 or enter * (asterisk) to list all extended parameters currently defined for this data
source. You can add, change, or delete an entry using options on the Action menu.
Parameters affecting data type precision or error mapping are the only ones likely to
be of interest.
2-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
The Mode field indicates the current mode of operation of the menu. To change
mode, use the Action menu on the menu bar. The Action menu has four options.
After you enter a data source name and a parameter, you can choose one of the
following actions:
Option Description
Add This is the default action. If the extended parameter is one value (for
example, MAXFETCHCOLS = 400), the new value overwrites the old
value. If the extended parameter has two values (for example, MAPERROR
= S0001 = 955), it is parsed to see if it should overwrite or be added to
the extended parameters of this data source.
List Lists all the extended parameters currently defined for this data source. This
output is the same as that produced by pressing F4 in the Parameter field
except that you cannot choose an entry.
Delete If the Parameter field is empty, the extended parameters of the data source
are listed, and you can choose an entry to delete. You cannot delete generic
parameters that were not set by a user.
Modify If the Parameter field is empty, the extended parameters of the data source
are listed, and you can select choose an entry to change. If the Parameter
field is blank, and the Mode is left as Modify, an error message appears
stating that the field cannot be blank. If you change a parameter name, the
original entry is unchanged. You can use Delete to remove the original
entry. If the extended parameter has two values (for instance, MAPERROR
= S0001 = 955), it is parsed to see if it should overwrite or be added to
the extended parameters of this data source.
Action Menu Options
At the Parameter prompt, enter ? (question mark) to list possible parameters. Press
F4 or enter * (asterisk) to see a list of all extended parameters currently defined for
UniVerse. The chosen entries can then be added, modified, or deleted by using the
options of the Action menu.
2-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
The Mode field indicates the current mode of operation of the menu. To change
mode, use the Action menu on the menu bar. The Action menu has four options.
After you enter a DBMS name and a parameter, you can choose one of the following
actions:
Action Description
Add This is the default action. If the extended parameter is one value (for example,
MAXFETCHCOLS = 400), the new value overwrites the old value. If the
extended parameter has two values (for instance, MAPERROR = S0001 =
955), it is parsed to see if it should overwrite or be added to the extended
parameters of this DBMS type.
List Lists all the extended parameters currently defined for this DBMS type. This
output is the same as that produced by pressing F4 in the Parameter field
except that you cannot choose an entry.
Delete If the Parameter field is empty, the extended parameters of the DBMS type
are listed, and you can choose an entry to delete. You cannot delete generic
parameters that were not set by a user.
Modify If the Parameter field is empty, the extended parameters of the DBMS type
are listed, and you can choose an entry to change. If the Parameter field is
blanked now, and the Mode is left as Modify, an error message appears stating
that the field cannot be blank. If you change the parameter name, the original
entry is unchanged. You can use Delete to remove the original entry. If the
extended parameter has two values (for instance, MAPERROR = S0001 =
955), it is parsed to see if it should overwrite or be added to the extended
parameters of this DBMS type.
See Chapter 3, “Using the CONNECT Command,” for details about the CONNECT
command. See Chapter 4 “Using the SQL Client Interface,” for details about the SQL
Client Interface.
2-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
Create a Schema
You must run the demonstration program as an SQL user with appropriate privileges,
and you must be in a UniVerse schema. To create a new schema on either a UNIX or
a Windows system, complete the following steps:
2-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch2
3/12/10
>
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
This chapter describes how to use the CONNECT command to connect to a data
source from a UniVerse client. You enter the CONNECT command at the UniVerse
prompt. The CONNECT command lets you submit SQL statements to the data source
and receive results at your terminal.
While you are connected to a data source, you can enter any SQL statement
understood by the data source’s DBMS engine, including SELECT, INSERT,
UPDATE, DELETE, GRANT, and CREATE TABLE. You cannot, however,
successfully submit commands understood only by a front-end tool at the server.
ODBC data sources can use SQL language that is consistent with the ODBC
grammar specification as documented in Appendix C of Microsoft ODBC 2.0
Programmer’s Reference and SDK Guide.
The CONNECT command runs in autocommit mode: that is, all changes made to the
data source’s DBMS are committed immediately. Do not use transaction control
statements such as BEGIN TRANSACTION, COMMIT, and ROLLBACK when
you are using CONNECT. For information about transactions, see Transaction
Management in Chapter 4, Using the SQL Client Interface.
Some database systems, such as SYBASE, treat SQL identifiers and keywords case-
sensitively, whereas others such as ORACLE and INFORMIX do not. UniVerse
treats SQL identifiers case-sensitively, but it treats SQL keywords as case-insen-
sitive. For example, in UniVerse and SYBASE a table or column called BUDGET is
different from one called Budget. ORACLE and INFORMIX treat these as
duplicates. Also, SYBASE requires you to specify data types (char, int, float, and so
forth.) in lowercase. In UniVerse, ORACLE, and INFORMIX you can use either
upper- or lowercase letters for these keywords.
Command Syntax
The syntax of the CONNECT command is as follows:
data.source is the name of the data source to which you want to connect. The data
source must be defined in the uvodbc.config file. If you do not enter the name of a
data source, CONNECT lists all data sources in the uvodbc.config file.
BLOCK PREFIX
INVERT UVOUT
MVDISPLAY VERBOSE
NULL WIDTH
Command Options
You can specify any option by typing the word or its first letter. Each option must be
followed by a setting. The following section describes the options and their possible
settings in detail.
3-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
BLOCK Option
The BLOCK option defines how input statements will be terminated. setting is one
of the following:
Setting Description
ON Enables block mode. In this mode you can enter a series of SQL statements,
ending each with a ; (semicolon). To terminate the block of SQL statements,
press ENTER immediately after an SQL+ prompt.
OFF Disables block mode. In this mode if you type a semicolon at the end of a
line of input, the SQL Client Interface terminates your input and sends it to
the data source. This is the default setting.
string Enables block mode (see ON, above). string must be from 1 to 4 characters.
To terminate the block of SQL statements, enter string immediately after an
SQL+ prompt.
BLOCK Settings
See “Executing SQL Statements on the Data Source” on page 13 for more details.
INVERT Option
The INVERT option lets you control case inversion for alphabetic characters you
type while CONNECT is running. setting is one of the following:
Setting Description
ON Inverts the case of all alphabetic characters you type—that is, lowercase
letters change to uppercase, and uppercase letters change to lowercase. This
is equivalent to setting PTERM CASE parameters to INVERT and LC-IN.
INIT Sets case-inversion parameters to the values they had when you invoked
CONNECT. This is the default setting for UniVerse data sources.
INVERT Settings
When you exit CONNECT, case inversion for input is restored to the state it was in
when you invoked CONNECT.
MVDISPLAY Option
The MVDISPLAY option defines how to display value marks in multivalued data
selected from a UniVerse data source. For each row, multiple values in the same field
are displayed on the same line, separated by value marks. setting is one of the
following:
Setting Description
NULL Option
The NULL option defines how to display the SQL null value. setting is one of the
following:
Setting Description
string Displays SQL null as string. The string can be from 1 to 4 characters. By
default, UniVerse displays null as the four-character string NULL.
NULL Settings
3-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
PREFIX Option
The PREFIX option defines the prefix character for local commands. setting is any
valid prefix character. The default prefix character is a period ( . ). You can use only
the following characters as the prefix character:
: colon . period
UVOUT Option
The UVOUT option specifies how to handle output from SELECT statements
executed on the data source. setting is either:
Setting Description
filename Stores output in filename on the client, then displays the output from
filename. If the file does not exist, the CONNECT command creates it.
OFF Displays output from the data source directly on the client’s screen. This
is the default setting.
UVOUT Settings
VERBOSE Option
The VERBOSE option displays extended column information and system messages.
setting is either:
Setting Description
ON Enables verbose mode. In this mode the name, SQL data type, precision,
scale, and display size are displayed for each column’s definition when
selecting data from the data source. Error messages are displayed in extended
format that includes the type of call issued, status, SQLSTATE, error code
generated by the data source, and the complete error text.
3-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
WIDTH Option
The WIDTH option defines the width of display columns. setting is one of the
following:
Option Description
col#,width Sets the width of column col# to width. Do not type a space after the comma.
Specify col# as * (asterisk) to set the width of all columns. width can be
from 4 to the maximum line length allowed by your terminal. The default
width for all columns is 10.
T Truncates data that is wider than the specified width. This is the default
setting.
F Folds data that is wider than the specified width onto multiple lines.
? Displays the current column width settings, and tells whether data will be
truncated or folded.
WIDTH Options
If you are connecting to a UniVerse data source, you are prompted to enter
your login name and password to connect to the server operating system.
Next you are prompted to enter the name of the schema or account you want
to connect to. You can enter a path in place of the schema or account name.
If you are connecting to an ODBC data source, you are prompted to enter
your user name and password to connect to the data source.
Be sure to enter these parameters in the proper upper- and lowercase letters. The
password is not echoed to the screen.
The user name and password must be valid on the server machine. The default user
name is your login name on the client system. You have three chances to enter your
user name and password correctly.
Note: You can connect to the local UniVerse server through a local connection or
through the RPC facility (remote procedure call). To connect locally, the data source
specification in the configuration file must specify localhost or the IP loopback
address 127.0.0.1. If you are using a local connection to connect to the local
UniVerse server, you are not prompted for your user name and password.
After you log on successfully to the server operating system, and if the DBMS is
currently running, the SQL Client Interface prompts you to enter the login parameters
you use to access the DBMS on the server. The following table lists login parameters
for each type of data source:
UNIVERSE Either a UniVerse account or schema name, or the full path where the
account or schema is located.
You have three chances to enter your data source parameters correctly.
3-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
Note: If you are using a local connection to connect to the local UniVerse server, you
are not prompted to enter a schema name or account name. You connect directly to
the schema or UniVerse account in which you are currently working.
After accepting the DBMS login parameters, the data source prompt appears:
data.source.name>
The next sections show examples of the login sequence on different systems.
Brackets enclose default entries, which you can accept by pressing ENTER.
To connect to the local UniVerse server through the RPC, the data source
specification in the configuration file must specify the host name of the local
UniVerse server. The following example shows what happens when you connect to
the local UniVerse server through the RPC:
>CONNECT uv
Enter your login name for server operating system [george]: fred
Enter password for fred (use SHIFT for lower case):
Enter name or path of remote schema/account [FRED]:<Return>
'FRED' is a non-existent or invalid schema/account on 'uv'
Enter name or path of remote schema/account [FRED]: SALES
uv>
uvserver is not defined in the uvrpcservices file of the UniVerse server. You
will see a message similar to the following example:
>CONNECT uv
SQLConnect error: Status = -1 SQLState = 08001 Natcode = 81016
[RPC] error code = 81016
Connection attempt to 'uv' failed; - RPC daemon probably not
running
The data source is not defined in the configuration file (for example, you
may have misspelled it). You will see a message similar to the following
example:
>CONNECT badname
Data source 'badname' not found in uvodbc.config
The server does not respond. This can be due to problems on the network or
problems with the server software. You will see a message similar to the
following example:
>CONNECT fred-vega-sybsrv
Enter username for connecting to 'fred-vega-sybsrv' DBMS
[VEGA\george]: fred
Enter password for fred:
SQLConnect error: Status = -1 SQLState = 01000 Natcode = 4
[ODBC:4][INTERSOLV][ODBC SQL Server driver][SQL
Server]ct_connect():
network packet lay
3-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
The configuration file contains incorrect information for the requested data
source or for its DBMS type. You will see a message similar to the following
example:
>CONNECT syb
SQLConnect error: Status = -1 SQLState = IM997 Natcode = 0
[SQL Client] An illegal configuration option was found
Invalid parameter(s) found in uvodbc.config file
If the DBMS is not currently running on the server, you will a message
similar to the following example:
SQLConnect error: Status = -1 SQLState = S1000 Natcode =
9352
How you terminate your SQL input depends on whether block mode is enabled or
disabled. If block mode is disabled (the default), you must end SQL statements with
a : (semicolon) or a ? (question mark). Statements ending with a semicolon are
executed on the data source. Statements ending with a question mark are not sent to
the data source but are stored on the client. The most recently entered statement is
stored on the client so you can recall it and edit it.
You can enter an SQL statement on several lines. If a statement line does not end with
a semicolon or a question mark and you press ENTER, the SQL continuation prompt
appears:
SQL+
You can terminate your input by pressing ENTER immediately after an SQL+
prompt. SQL statements can be up to 38 lines long.
If block mode is enabled, a semicolon does not terminate your input. SQL statements
are sent to the data source for execution only when you press ENTER or enter a
termination string immediately after an SQL+ prompt. SQL statements ending with
a question mark are not sent to the data source; they are stored on the client.
Use the BLOCK option of the CONNECT command or the local command .BLOCK
to enable and disable block mode.
You can enable block mode in two ways. With block mode set to ON, you terminate
input by pressing ENTER immediately after an SQL+ prompt.
3-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
With block mode set to a character string, you enter the character string immediately
after an SQL+ prompt to terminate input. For example, you might want to terminate
your input with a line such as GO. The string can be up to four characters long. The
string is not case-sensitive, so if you specify GO with the BLOCK option or the .B
command, for example, you can terminate input with GO or go.
You can enter local commands as a word or as the first letter of the word. Local
commands cannot end with a semicolon or a question mark. The following are valid
local commands:
Command Description
.B [ LOCK ] setting Enables or disables block mode. setting can be ON, OFF,
or a character string. See “Executing SQL Statements on
the Data Source” on page 13 for details.
.N [ ULL ] setting Defines how to display the SQL null value. setting can be
SPACE, NOCONV, or a character string.
3-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
Command Description
.R [ ECALL ] [ name ] Displays, but does not execute, the SQL statement stored
as name in the VOC. If you do not specify name,
.RECALL displays the most recent SQL statement.
.S [ AVE ] name Saves the most recent SQL statement as the sentence
name in the VOC file.
In UniVerse output mode, CONNECT writes each row of data to a UniVerse file on
the client (the file is first cleared). It then generates a UniVerse SQL SELECT
statement that displays the data in the file.
In both output modes, data is left-justified if its type is CHAR or DATE, text-justified
if its type is VARCHAR, and right-justified if it is any other data type.
You can use UniVerse output mode to transfer data from the data source to your
UniVerse database. This is because output from a SELECT statement is stored in a
UniVerse file. However, each SELECT clears the UniVerse output file before writing
output to it. If you want to save the results of several SELECTs in your UniVerse
database, you must use several UniVerse output files.
3-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
Examples
The following example shows a normal login to a UniVerse data source:
>CONNECT uv
Enter your login name for server operating system [josh]:<Return>
Enter password for josh (use SHIFT for lower case):
Enter name or path or remote schema/account [JOSH]: SALES
uv> LIST VOC
SQL+
[UNIVERSE:930145] UniVerse/SQL: LIST not a SQL DDL or DML verb.
uv> SELECT * FROM VOC LPTR;
[UNIVERSE:930142] UniVerse/SQL: Most Report Qualifiers are not
supported for Clients, scanned command was FROM VOC SELECT * LPTR;
uv> .C/LPTR/SAMPLE 2
SELECT * FROM VOC SAMPLE 2
uv> .X
NAME TYPE DESC
-------------- ---- -----------------------------------
GLOBAL.CATDIR F File - Used to access system c*
STAT V Verb - Produce the STAT of a n*
2 rows selected
uv> .Q
Disconnecting from 'uv'
>
The LIST command fails because the server accepts only DDL and DML statements
from the client. The first SELECT statement fails because LPTR is not valid in
programmatic SQL. The second SELECT statement succeeds, and the user
disconnects from the data source.
The next example shows a normal login to an ODBC data source running SYBASE.
Some data is selected from a table.
>CONNECT syb
Enter username for connecting to 'syb' DBMS [hatch]:<Return>
Enter password for hatch:
syb> select * from tedtab1;
pk colchar8 colint colreal
---------- -------- ---------- ----------
1 New York 9876 3.40000009*
2 Chicago 543 23.3999996*
2 rows selected
2 rows selected
syb> .v off
syb> .w f
syb> .x
pk colchar8 colint colfloat
---------- -------- ---------- ----------
1 New York 9876 3.40000009-
5
2 Chicago 543 23.3999996-
19
2 rows selected
syb> .w 4,15
syb> .x
pk colchar8 colint colfloat
---------- -------- ---------- ----------
1 New York 9876 3.400000095
2 Chicago 543 23.399999619
3-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
2 rows selected
syb> .w
Truncate/Fold mode is: F
Column width settings are:
Column 4: 15
All other columns: 10
2 rows selected
By changing the display width of column 4 to 15 characters, you get the following
display:
syb> .w 4,15
syb> .x
pk colchar8 colint colreal
---------- -------- ---------- ---------------
1 New York 9876 3.400000095
2 Chicago 543 23.399999619
2 rows selected
To display the current display width settings, use a question mark after the .W
command, as follows:
syb> .w ?
Truncate/Fold mode is: F
Column width settings are:
Column 4: 15
All other columns: 10
Exiting CONNECT
The next example inserts values into a table, selects and displays them, then quits
from CONNECT:
syb> insert into tedtab3 values (3,9,1,8);
1 row affected
syb> select * from tedtab3;
pk coltinyint colbit colsmint
---------- ---------- ---------- ---------------
1 255 0 -32768
2 0 0 32768
3 9 1 8
3 rows selected
syb> .q
Disconnecting from 'syb' database
>
First, enter UniVerse output mode while you are connected to the data source ora:
ora> .U UVFILE1
Opening file UVFILE1
detroit lions
pittsburgh steelers
new york giants
3 records listed.
3-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch3
3/12/10
Now switch to a different UniVerse output file and enter another SELECT statement:
ora> .U UVFILE2
Closing file UVFILE1
Creating file "UVFILE2" as Type 30.
Creating file "D_UVFILE2" as Type 3, Modulo 1, Separation 2.
Added "@ID", the default record for RetrieVe, to "D_UVFILE2".
Opening file UVFILE2
ora> SELECT DISTINCT COLM, COLM+3, COLM*7 FROM TEDTAB7;
COLM...... COLM+3.... COLM*7....
0 3 0
1 4 7
4 7 28
6 9 42
4 records listed.
Next, exit CONNECT and enter two SELECT statements, one on UVFILE1 and one
on UVFILE2:
ora> .Q
Disconnecting from 'ora' database
>SELECT * FROM UVFILE1;
COLC...... COLD......
detroit lions
pittsburgh steelers
new york giants
3 records listed.
>SELECT * FROM UVFILE2;
COLM...... COLM+3.... COLM*7....
6 9 42
0 3 0
1 4 7
4 7 28
4 records listed.
>
2 rows selected
The next example enables block mode and creates a stored procedure on an ORACLE
database:
ora> .B ON
ora> CREATE PROCEDURE sal_raise (emp_id IN NUMBER,
SQL+sal_incr IN NUMBER) AS
SQL+BEGIN
SQL+UPDATE emp
SQL+SET sal = sal + sal_incr
SQL+WHERE empno = emp_id;
SQL+IF SQL%NOTFOUND THEN
SQL+raise_application_error (-20011, 'Invalid Employee Number:'||
SQL+TO_CHAR (emp_id));
SQL+END IF;
SQL+END sal_raise;
SQL+<Return>
ora>
3-23
2Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
UniVerse BASIC programs use the SQL Client Interface to exchange data between a
UniVerse client and a server data source. A data source is a network node and a DBMS
on that node. For example, you might have an order entry system on the machine
running UniVerse and want to post this information to a central database. You use the
SQL Client Interface to connect your applications to the data source and exchange
data.
4-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
As of Release 9, each UniVerse process opens a local connection to itself. This is true
for both user and server processes. BASIC programs running on a UniVerse server
can use the @variables @HENV, @HDBC, and @HSTMT to refer to this local
connection. Using these @variables in your programs lets you execute programmatic
SQL statements without having to allocate SQL Client Interface, connection, and
statement environments.
Certain combinations of UniVerse client and server may not reliably transfer data
because of a mismatch in the locale settings at the client end. The following sections
show which combinations of server locale specifications are allowed depending on
the type of client and the NLS states of both client and server.
Note: The SQL Client Interface can connect to an ODBC data source only if the client
system is running with NLS mode turned off.
Release 9.4 (or Later) Client and Release 9.4 (or Later)
Server
The following table shows which combinations of locale specifications are allowed
depending on the NLS status of the client and the server.
Server NLS
Locale
State Client NLSLocaleState Action
OFF, and not requested via Server default locale used if valid.
SQLSetConnectOption
OFF ON Connection rejected unless requested
locale is WIN:0409, US-ENGLISH, or
OFF.
Release 9.3 (or Earlier) Client and Release 9.4 (or Later)
Server
UniVerse releases before 9.4 do not support NLS. Therefore any Release 9.3 (or
earlier) client can connect to a Release 9.4 (or later) server only if the default server
map as set by the NLSDEFSRVMAP is ISO8859-1+MARKS or ASCII+MARKS. If
server locale support is enabled, NLSDEFSRVLC is used, if valid.
Release 9.4 (or Later) Client and Release 9.3 (or Earlier)
Server
Because UniVerse releases before 9.4 do not support NLS, Release 9.4 (or later)
clients can connect to Release 9.3 (or earlier) servers only if the requested locale is
WIN:0409, US-ENGLISH, or OFF.
4-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
UniVerse BASIC programs running locally on a UniVerse server can use the
@variable @HENV to refer directly to the SQL Client Interface environment. They
do not need to allocate one.
UniVerse BASIC programs running locally on a UniVerse server can use the
@variable @HDBC to refer directly to the connection environment. They do not
need to allocate one.
You do not use SQLSetConnectOption for login ID and password if you are
connecting to the localuv server.
Use SQLConnect to establish a session between your application and the DBMS on
the server. A BASIC program running locally on a UniVerse server does not need to
execute SQLConnect. It is automatically connected to the localuv server, at the
schema or account where the program is running. When connecting to a remote
UniVerse server, the SQLConnect function contains an account or schema name, or
a path specifying where the UniVerse data source is located. When connecting to an
ODBC server, SQLConnect contains the name of the data source and information
needed to log on to the data source. After the connection is established, you can
allocate an SQL statement environment to prepare to process SQL statements.
The server honors the following configurable parameters in the uvconfig file:
Parameter Description
NLSLCMODE Switches locale support on or off. A value of 1 enables locales for the
whole UniVerse system. The value is ignored if NLSMODE is set to
0. A value of 0 turns off locales even if NLSMODE is set to 1.
NLSDEFSRVLC Specifies the default locale for a UniVerse server, which is used by all
client programs accessing the server.
NLS-Enabled Configuration Parameters
When the client application starts, it determines the default locale values to send to
the server as follows:
Client programs can use the SQLSetConnectOption to override any of the default
locale values.
4-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
You can establish more than one SQL statement environment for the same connection
environment.
BASIC programs running locally on a UniVerse server can use the @variable
@HSTMT to refer directly to the SQL statement environment. They do not need to
allocate one.
Direct execution
Prepared execution
Your SQL statements must conform to the SQL language and conventions supported
by the server’s DBMS engine. For example, you cannot execute RetrieVe commands
on a UniVerse data source, or SQL*Plus commands such as DESCRIBE on an
ORACLE data source. ODBC data sources can use SQL language that is consistent
with the ODBC grammar specification as documented in Appendix C of the
Microsoft ODBC 2.0 Programmer’s Reference and SDK Guide.
4-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
If you are executing SQL statements on an ODBC data source running SYBASE,
remember that it may treat identifiers and keywords case-sensitively. Also, if you are
connected to an ODBC data source and you execute a stored procedure or enter a
command batch with multiple SELECT statements, the results of only the first
SELECT statement are returned.
For example, if you are inserting many data rows in a table, use the SQLPrepare
function once, then use one SQLExecute for each row you insert. Before each
SQLExecute call, set new values for the data to insert. To set new data values, you
use parameter markers in your SQL statement (see “Using Parameter Markers in
SQL Statements” on page 9). Using the SQLPrepare and SQLExecute functions in
this way is more efficient than using separate SQLExecDirect calls, one for each
row.
To insert data into this table, you might use SQLExecDirect to execute a series of
INSERT statements. For example:
STATUS = SQLExecDirect(STMTENV,"INSERT INTO STAFF VALUES ('E9',
'Edward',
10, 'Arlington')")
STATUS = SQLExecDirect(STMTENV,"INSERT INTO STAFF VALUES ('E10',
'John',
12, 'Belmont')")
STATUS = SQLExecDirect(STMTENV,"INSERT INTO STAFF VALUES ('E11',
'Susan',
13, 'Lexington')")
STATUS = SQLExecDirect(STMTENV,"INSERT INTO STAFF VALUES ('E12',
'Janet',
13, 'Waltham')")
The SQLExecDirect function takes two input variables. The first, STMTENV, is the
name of the SQL statement environment. The second is the INSERT statement to be
sent to the data source for execution.
Using several SQLExecDirect calls to insert data in this way is relatively slow. A
better way to do this is to prepare the following INSERT statement for execution:
Before you execute this statement, use SQLBindParameter calls to inform the SQL
Client Interface where to find the parameter values to use in the statement. For
example:
STATUS = SQLBindParameter(STMTENV, 1, SQL.B.BASIC, SQL.CHAR, 3, 0,
EMPNUM)
STATUS = SQLBindParameter(STMTENV, 2, SQL.B.BASIC, SQL.CHAR, 20,
0, EMPNAME)
STATUS = SQLBindParameter(STMTENV, 3, SQL.B.BASIC, SQL.INTEGER, 0,
0, GRADE)
STATUS = SQLBindParameter(STMTENV, 4, SQL.B.BASIC, SQL.CHAR, 15,
0, CITY)
STATUS = SQLPrepare(STMTENV, "INSERT INTO STAFF VALUES ( ?, ?, ?,
4-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
? )")
.
.
.
EMPNUM = 'E9'
EMPNAME = 'Edward'
GRADE = 10
CITY = 'Arlington'
STATUS = SQLExecute(STMTENV)
EMPNUM = E10'
EMPNAME = 'John'
GRADE = 12
CITY = 'Belmont'
STATUS = SQLExecute(STMTENV)
.
.
.
You can also use parameter markers with SELECT statements when you want to
specify variable conditions for queries. For example, you might use the following
statements to select rows from STAFF when CITY is a variable loaded from your
application:
STATUS = SQLBindParameter(STMTENV, 1, SQL.B.BASIC, SQL.CHAR, 15,
0, CITY)
STATUS = SQLPrepare(STMTENV, "SELECT * FROM STAFF WHERE CITY = ?")
PRINT "ENTER CITY FOR QUERY":
INPUT CITY
STATUS = SQLExecute(STMTENV)
You use the SQLNumResultCols function to find out how many columns the SQL
statement produced in the result set. If it finds columns, you can use SQLDescribeCol
or SQLColAttributes to get information about a column, such as its name, the SQL
data type it contains, and (on UniVerse data sources) whether it is defined as
multivalued.
You use the SQLRowCount function to find out if the SQL statement changed any
rows in the table. For example, if an SQL UPDATE statement changes 48 rows,
SQLRowCount returns 48.
If an SQL statement produces a set of results at the data source, we say that a cursor
is opened on the result set. You can think of this cursor as a pointer into the set of
results, just as a cursor on a screen points to a particular line of text. An open cursor
implies that there is a set of results pending at the data source.
To bring the results of the SQL statement from the data source to your application,
use the SQLBindCol and SQLFetch functions. You use SQLBindCol to inform the
SQL Client Interface where to put data from a specific column and what application
data type to store it as. For example, to print rows from the STAFF table, you might
write the following:
SQLBindCol(STMTENV, 1, SQL.B.DEFAULT, EMPNUM)
SQLBindCol(STMTENV, 2, SQL.B.DEFAULT, EMPNAME)
SQLBindCol(STMTENV, 3, SQL.B.DEFAULT, EMPGRADE)
SQLBindCol(STMTENV, 4, SQL.B.DEFAULT, EMPCITY)
LOOP
WHILE STATUS <> SQL.NO.DATA.FOUND DO
STATUS = SQLFetch(STMTENV)
IF STATUS <> SQL.NO.DATA.FOUND
THEN
PRINT EMPNUM form:EMPNAME form:EMPGRADE form:EMPCITY
END
REPEAT
The SQLBindCol function takes four input variables. The first, STMTENV, is the
name of the SQL statement environment. The second is the number of the column.
The third specifies the data type to which to convert the incoming data. The fourth is
the name of the variable where the column value is stored.
For each column, a call to SQLBindCol tells the SQL Client Interface where to put
each data value when SQLFetch is issued. Each SQLFetch stores the next row of
data in the specified variables. Normally you fetch data rows until the end-of-data
status flag is returned to the SQLFetch call.
4-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
The SQL.B.DEFAULT argument to SQLBindCol lets the result column’s SQL data
type determine the BASIC data type to which to convert data from the data source.
For information about converting data, see Appendix A, “Data Conversion.”
For other examples showing how to execute SQL statements, see Appendix B, “SQL
Client Interface Demonstration Program.”
For example, the following statement frees the SQL statement environment in the
demonstration program (see Appendix B, “SQL Client Interface Demonstration
Program”):
STATUS = SQLFreeStmt(STMTENV, SQL.DROP)
Use SQLFreeEnv to release the SQL Client Interface environment and all resources
associated with it. Disconnect all sessions with the SQLDisconnect and
SQLFreeConnect functions before you use SQLFreeEnv.
The following example shows some function calls used in a BASIC application.
4-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
SQLAllocEnv
SQLAllocConnect
SQLSetConnectOption
SQLConnect
SQLAllocStmt
Receive results
SQLFreeStmt
CLOSE option
SQLFreeConnect
SQLFreeEnv
The next example shows the order of function calls you use to execute a simple SQL
statement.
4-16
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
Set up connection
Repeatable
execution?
No Yes
SQLBindParameter SQLBindParameter
SQLPrepare
SQLExecDirect
SQLExecute
Statement type
UPDATE, INSERT,
SELECT statement or DELETE statement
SQLNumResultCols
SQLDescribeCol SQLRowCount
SQLBindCol
SQLFetch
More
Yes rows?
No
SQLFreeStmt
If repeat
Disconnect
Transaction Management
Use the UniVerse BASIC statements BEGIN TRANSACTION, COMMIT,
ROLLBACK, and END TRANSACTION to provide transaction management
control in your application.
Distributed Transactions
A distributed transaction is a transaction that updates more than one data source or
that updates a local UniVerse database and one or more data sources. Be careful when
you use distributed transactions. The UniVerse transaction manager does not support
the two-phase commit protocol that ensures that all operations are either committed
or rolled back properly. If a COMMIT fails, the systems involved may be out of sync,
since the local part of the COMMIT can succeed even though the remote part fails.
If your program uses distributed transactions, you must ensure that it can recover
from a COMMIT failure, or that enough information is available to let you manually
restore the databases to a consistent state.
4-18
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
Nested Transactions
UniVerse supports nested transactions—that is, within any transaction you can begin
and end one or more subtransactions. Only one transaction is active at any time,
although a transaction and several subtransactions may exist simultaneously. Each
nested transaction exists on its own transaction nesting level. When no transaction
currently exists, the program is at transaction nesting level 0.
An SQLFetch call must be issued at the same, or deeper, transaction nesting level as
the SQLExecute or SQLExecDirect call associated with it; it cannot be issued at a
higher nesting level. This is because the cursors opened within a transaction are
closed when that transaction is committed or rolled back.
4-20
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
Detecting Errors
Any SQL Client Interface function call can generate errors. Use the SQLError call
after any function call for which the returned status indicates an error condition.
ODBC data sources generally return a consistent error for the same error condition.
Each DBMS returns its own error code in response to SQL statements that generate
errors. The same SQL statement generating the same type of error usually has a
different error code, depending on the particular data source DBMS. For example,
when you try to drop a nonexistent table, each DBMS generates a different native
error code.
You can use the MAPERROR parameter in the configuration file to map DBMS error
codes to a common SQLSTATE value. This makes it easier to write applications that
are portable among supported DBMSs. For example, suppose an SQL statement
returns an illegal option error code of 950999 from UniVerse, 1234 from ORACLE
and –777 from INFORMIX-OnLine. Your program can test for this error condition
by checking for an SQLSTATE value of S1009, regardless of which DBMS it is
connected to, if the following MAPERROR statements are in the uvodbc.config file:
The SQL Client Interface provides default mappings for the following common error
types:
For more information about error codes, see Appendix C, “Error Codes.”
Errors can be detected by the SQL Client Interface, by the UniRPC, by the ODBC
driver, or by the data source. See the SQLError function in Chapter 7, “SQL Client
Interface Functions,” for more information.
Error conditions such as syntax errors are returned to the client program with an error
code and an SQLSTATE value. Client programs should check the return status of
every function call issued, including calls that request the UniVerse server to execute
a programmatic SQL statement. The client program should use the SQLError call to
determine the reason for the error.
SQLSTATE Values
The SQLError function provides an SQLSTATE value, a UniVerse error code, and
the error message text. The following table shows all possible SQLSTATE values
returned by SQLError, with examples of a UniVerse error code and text. For a
complete list of SQLSTATE values, see Appendix C, “Error Codes.”
SQLSTATE Description
21S01 The number of columns inserted does not match the number expected.
For example:
950059 Number of columns inserted does not match number required.
21S02 The number of columns selected does not match the number defined in a
CREATE VIEW statement. For example:
950415 More explicit column names than column selected.
4-22
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch4
3/12/10
SQLSTATE Description
42000 User lacks SQL privilege or operating system permissions for this
operation. For example:
950076 Permission needed to insert records in table "INVENTORY".
S1000 A general error was detected by the data source (server). For example:
950427 An association column must be multivalued.
Client Program Error Codes (Continued)
Fatal UniVerse errors that use error codes from 050000 through 050020 cause the
application program to exit and return to the UniVerse prompt. Fatal UniVerse errors
outside this range of error codes return the program to the previous execution
environment and set the @SYSTEM.RETURN.CODE variable to –1.
The next two commands display two connection environment variables, ODBC1 and
ODBC2:
::ODBC1/
This is an ODBC connection environment variable.
It is connected and has 1 statement environment(s).
::ODBC2/
This is an ODBC connection environment variable.
It is not connected.
The next command displays the SQL statement environment variable STMTENV:
::STMTENV/
This is an ODBC statement environment variable.
4-24
3Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
This chapter describes how to call and execute procedures stored on a UniVerse data
source.
Client programs can call and execute procedures that are stored on a database server.
Procedures can accept and return parameter values and return results to the calling
program.
Procedures let developers predefine database actions on the server. Procedures can
provide a simple interface to users, insulating them from the names of tables and
columns as well as from the syntax of SQL. Procedures can enforce additional
database rules beyond simple referential integrity and constraints. Such rules need
not be coded into each application that references the data, providing consistency and
easy maintenance.
5-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch5
3/12/10
If you call a UniVerse BASIC subroutine, you use the following CALL statement
syntax, which lets you pass a comma-separated list of parameters within parentheses
as arguments to the subroutine:
Parameters can be literals or parameter markers. The number and order of parameters
must correspond to the number and order of arguments expected by the subroutine.
For example, to call subroutine SUBX which requires a file name and a field name
as arguments, you can use SQLExecDirect to execute a call statement, such as:
Or you could bind parameter number 1 to a program variable, load the desired field
name into that variable, and execute:
The second format for the CALL statement is used to call a UniVerse BASIC
program or a Universe command that accepts a string of arguments after the verb. In
this case you use the standard UniVerse syntax after the procedure name, which lets
you specify keywords, literals, and other tokens as part of the command line. You
cannot use parameter markers with this syntax. You do not use parentheses, nor do
you separate arguments with commas:
For example, to obtain a listing of the first three records in MYFILE, call the
UniVerse LIST command by executing:
5-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch5
3/12/10
Note: Information about the SQL result of a CALL statement is not available until
after the statement has been executed. Therefore, if you SQLPrepare a CALL
statement and then want to use SQLNumResultCols, SQLColAttributes, or
SQLRowCount, you must first SQLExecute the statement. Otherwise the
SQLNumResultCols (etc.) call receives a function sequence error (SQLSTATE =
S1010).
Every call to a UniVerse procedure produces one of the following SQL results:
Affected-Row Count
If there are no result columns (SQLNumResultCols returns 0), the application can
find out how many rows were affected in the database by calling SQLRowCount.
5-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch5
3/12/10
Calls to some UniVerse procedures return a status of SUCCESS even though the
procedure encountered some kind of error. This is true for many procedures which
produce a print result set (paragraphs, commands, procs, and some UniVerse BASIC
programs). The client application might have to examine the contents of the print
result set or display it for a user, in order to determine whether the procedure executed
correctly. For example, suppose a client issues the following call:
where BADF is not a valid field name in MYFILE. Execution of this call returns
SUCCESS status, and the print result set contains the following error message
produced by the UniVerse server when it tried to execute the CREATE.INDEX
command:
Cannot find field name BADF in file dictionary or VOC,
no index created.
SQLNumResultCols
SQLColAttributes
SQLRowCount
5-8
4Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
A UniVerse procedure is a program that runs on a UniVerse server and can be called
by UCI and BCI client applications. Client applications call a procedure by executing
an SQL CALL statement. A UniVerse procedure can be any of the following:
A UniVerse command
A remote command
A paragraph or stored sentence
A proc (ProVerb)
A UniVerse BASIC program
A UniVerse BASIC subroutine
This chapter discusses the rules for using paragraphs, commands, and procs as
procedures. It also discusses how to write UniVerse BASIC procedures including
input and output parameters, result set generation, and the types of errors that can be
produced by a UniVerse BASIC procedure.
6-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
If user input is required (if a paragraph contains the <<...>> syntax for inline
prompting, for example), the input must be supplied by DATA statements.
The paragraph, command, or proc cannot invoke a UniVerse menu.
The paragraph, command, or proc cannot invoke any of the following
UniVerse commands:
Note: The special print file used to store a print result set does not affect the behavior
of print-capturing commands, such as COMO or SPOOL, that might be invoked by
the paragraph, command, or proc.
The writer of a UniVerse BASIC procedure should specify its characteristics so that
client application programmers know how to call the procedure and what results it
will return. These characteristics should include:
6-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
For example, a UniVerse BASIC procedure that takes one input parameter (employee
number) and returns one output parameter (person’s name) might be coded roughly
as follows:
SUBROUTINE GETNAME (EMPNO,PERSON)
OPEN "EMPS" TO EMPS ELSE...
READ INFO FROM EMPS,EMPNO ELSE...
PERSON = INFO<1>
RETURN
A client application would call this procedure with program logic such as the
following:
All output lines that would normally be sent to the terminal screen during the
execution of a procedure are stored in a special print file; in the case of a UniVerse
BASIC procedure, this would, of course, include any PRINT statements issued by the
UniVerse BASIC program. The contents of this special print file will become a one-
column print result set unless the procedure overrides this default behavior and forces
one of the other types of SQL result.
Note: @HSTMT is the only variable that can be used to generate a multicolumn
result set or an affected-row count. Other variables can be allocated and used within
a procedure, but their results are strictly internal to the procedure.
6-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
The following sample server and client programs show how to use procedures to
simplify a client program’s access to the numbers and names of employees in various
departments. The procedures use a table called EMPS, whose key column is
EMPNUM and whose data columns are EMPNAME and DEPNUM.
Procedure
This UniVerse BASIC subroutine, SHOWDEPT, uses the @HSTMT variable to
execute a SELECT statement on the server. The SELECT statement returns a multi-
column result set containing employee numbers and names from the EMPS table.
SUBROUTINE SHOWDEPT(DEPT)
$INCLUDE UNIVERSE.INCLUDE ODBC.H
SELSTMT = "SELECT EMPNUM, EMPNAME FROM EMPS WHERE DEPNUM=":DEPT
ST = SQLExecDirect(@HSTMT, SELSTMT)
RETURN
Client Program.
The following fragment of a BCI client program, LIST.EMPLOYEES, calls the
SHOWDEPT subroutine as a procedure (the same could be done with a UCI client
program):
.
.
.
PRINT "ENTER DEPT NUMBER"
INPUT DEPTNO
ST=SQLBindParameter(HSTMT, 1, SQL.B.BASIC, SQL.INTEGER, 4, 0,
DEPTNO)
ST=SQLExecDirect(HSTMT, "CALL SHOWDEPT(?)")
ST=SQLBindCol(HSTMT, 1, SQL.B.NUMBER, EMPNO)
ST=SQLBindCol(HSTMT, 2, SQL.B.CHAR, NAME)
LOOP
Sample Output
When the client program runs, output such as the following appears on the terminal
screen:
>RUN BP LIST.EMPLOYEES
ENTER DEPT NUMBER
?123
4765 John Smith
2109 Mary Jones
365 Bill Gale
.
.
.
Procedure
This UniVerse BASIC subroutine, FIXDEPT, uses the @HSTMT variable to execute
an UPDATE statement on the server, which changes the department number in the
EMPS table for all employees in a particular department:
SUBROUTINE FIXDEPT(OLDDEPT,NEWDEPT)
$INCLUDE UNIVERSE.INCLUDE ODBC.H
UPDSTMT = "UPDATE EMPS SET DEPNUM = ":NEWDEPT
UPDSTMT := " WHERE DEPNUM = ":OLDDEPT
ST=SQLExecDirect(@HSTMT, UPDSTMT)
RETURN
Client Program
The following fragment of a BCI client program, CHANGE.DEPT, calls the
FIXDEPT subroutine as a procedure (the same could be done with a UCI client
program):
.
.
.
PRINT "ENTER OLD DEPT NUMBER: ": ; INPUT OLD
PRINT "ENTER NEW DEPT NUMBER: ": ; INPUT NEW
ST = SQLExecDirect(HSTMT, "CALL FIXDEPT(":OLD:",":NEW:")")
IF ST = 0 THEN
6-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
ST = SQLRowCount(HSTMT,ROWS)
PRINT "Department number ":OLD:" has been changed to ":NEW:
PRINT " for ":ROWS:" employees."
END ELSE
PRINT "The EMPS table could not be updated."
END
.
.
.
Sample Output
When the client program runs, output such as the following bold appears on the
terminal screen:
>RUN BP CHANGE.DEPT
ENTER OLD DEPT NUMBER: ?901
ENTER NEW DEPT NUMBER: ?987
Department number 901 has been changed to 987 for 45 employees.
When the SQL SELECT is executed, the virtual @TMP file appears to have a
number of rows equal to the number of “rows” in DARRAY. The SQL SELECT can
reference virtual fields in @TMP named F1, F2, F3, …, F23, which represent up to
23 text-mark-separated “columns” in DARRAY. The @TMP file also appears to have
an @ID field containing the entire contents of each “row” in DARRAY (the length
of each “row” is not subject to the 255-character limit usually associated with @ID
in UniVerse files).
The virtual @TMP file can be used in any SQL SELECT statement, including joins
and unions. @TMP cannot be referenced with INSERT, UPDATE, or DELETE
statements, however.
The use of @TMP is illustrated in the following example. A client application calls
a UniVerse BASIC procedure to obtain a list of employees whose department is
located in New Hampshire, along with their department number and zip code, sorted
by department number. The EMPS table does not indicate which state and zip code
each department is located in; this information is determined from a list in the
procedure program itself.
Procedure
This UniVerse BASIC subroutine FINDEMPS builds a dynamic array consisting of
department number, zip code, and employee name for each employee who works in
a specified state. It then saves this dynamic array in select list 9, and uses the
@HSTMT variable to execute an SQL SELECT from the virtual @TMP file
specifying select list 9 as the source of the data. The SELECT statement contains an
ORDER BY clause to sort the output by department number.
SUBROUTINE FINDEMPS(INSTATE) ; * Returns dept, zip code, name
sorted
by dept
$INCLUDE UNIVERSE.INCLUDE ODBC.H
DARRAY = ""
OPEN "EMPS" TO FVAR ELSE PRINT "OPEN ERROR" ; RETURN
SELECT FVAR
LOOP
READNEXT EMPNUM THEN
READ EMPREC FROM FVAR,EMPNUM ELSE PRINT "READ ERROR" ; RETURN
NAME = EMPREC<1> ; * EMPREC field 1 contains employee name
DEPT = EMPREC<2> ; * EMPREC field 2 contains department number
GOSUB GETSTATE ; * GETSTATE (not shown) returns STATE & ZIP for
this
DEPT
IF STATE = INSTATE THEN
IF DARRAY <> "" THEN DARRAY := @FM
DARRAY := DEPT:@TM:ZIP:@TM:NAME ;* Add 1 "row" with 3
6-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
"columns" to
DARRAY
END
END ELSE EXIT
REPEAT
SELECT DARRAY TO 9 ; * Save DARRAY in select list 9
ST=SQLExecDirect(@HSTMT, "SELECT F1,F2,F3 FROM @TMP SLIST 9 ORDER
BY 1")
RETURN
Client Program
The following fragment of a BCI client program EMPS.IN.STATE calls the
FINDEMPS subroutine as a procedure (the same could be done with a UCI client
program):
.
.
.
PRINT "ENTER STATE: ": ; INPUT SSS
ST = SQLExecDirect(HSTMT, "CALL FINDEMPS('":SSS:"')")
IF ST = 0
THEN
ST = SQLBindCol(HSTMT, 1, SQL.B.NUMBER, DEPTNO)
ST = SQLBindCol(HSTMT, 2, SQL.B.NUMBER, ZIPCODE)
ST = SQLBindCol(HSTMT, 3, SQL.B.CHAR, EMPNAME)
LOOP
WHILE SQL.SUCCESS = SQLFetch(HSTMT) DO
PRINT DEPTNO '4R' :" ":ZIPCODE '5R%5' :" ":EMPNAME
REPEAT
END
.
.
.
Sample Output
When the client program runs, output such as the following appears on the terminal
screen:
>RUN BP EMPS.IN.STATE
ENTER STATE: ?NH
529 03062 Ann Gale
529 03062 Fred Pickle
987 03431 John Kraneman
989 03101 Edgar Poe
.
.
.
A UniVerse BASIC procedure can generate an SQL error either indirectly (by issuing
an SQL statement that causes an error) or directly (by using the UniVerse BASIC
SetDiagnostics function).
If the last SQL statement issued (using @HSTMT) within the procedure before it
returns to the caller encountered an error, that error condition is passed back to the
calling client application, as shown in the following example.
Procedure
This procedure ADDEMP can be called to add a new employee to the EMPS table:
SUBROUTINE ADDEMP(NEWNUM,NEWNAME,NEWDEPT)
$INCLUDE UNIVERSE.INCLUDE ODBC.H
INSSTMT = "INSERT INTO EMPS VALUES (":NEWNUM
INSSTMT := ",'":NEWNAME:"',":NEWDEPT:");"
ST=SQLExecDirect(@HSTMT, INSSTMT)
RETURN
Client Program
The following fragment of a BCI client program NEW.EMPLOYEE calls the
ADDEMP subroutine as a procedure, providing information about a new employee
but erroneously assigning him an existing employee number (the same could be done
with a UCI client program):
.
.
.
EMPNO = 2109
FIRSTLAST = "Cheng Du"
DEPNO = 123
CALLSTMT = "CALL ADDEMP (":EMPNO
CALLSTMT := ",'":FIRSTLAST
CALLSTMT := "',":DEPNO:");"
PRINT "The CALL statement is: ":CALLSTMT
ST = SQLExecDirect(HSTMT, CALLSTMT)
6-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
IF ST <> 0 THEN
ERST =
SQLError(SQL.NULL.HENV,SQL.NULL.HDBC,HSTMT,STATE,CODE,MSG)
PRINT "SQLSTATE = ":STATE:", UniVerse error code = ":CODE:",
Error text ="
PRINT MSG
END
.
.
.
Sample Output
When the client program runs, output such as the following appears on the terminal
screen:
>RUN BP NEW.EMPLOYEE
The CALL statement is: CALL ADDEMP (2109,'Cheng Du',123);
SQLSTATE = S1000, UniVerse error code = 950060,
Error text = [Ardent][SQL
Client][UNIVERSE]UniVerse/SQL:
Attempt to insert duplicate record "2109" is illegal.
A procedure can force an error condition to be returned by using the UniVerse BASIC
SetDiagnostics function. This function sets a procedure-error condition and stores
error text (supplied by the procedure) in the SQL diagnostics area associated with
@HSTMT. The error condition remains in effect until the next programmatic SQL
statement, or ClearDiagnostics, is issued. In particular, the error condition will be
detected by the calling client application if the procedure returns before issuing
another SQL statement.
Procedure
This procedure DELEMP can be called to delete an employee from the EMPS table:
SUBROUTINE DELEMP(OLDNUM)
OPEN "EMPS" TO FVAR ELSE PRINT "OPEN ERROR" ; RETURN
READU REC FROM FVAR,OLDNUM THEN
DELETE FVAR,OLDNUM
END ELSE
JUNK = SetDiagnostics("Employee ":OLDNUM:" does not exist")
END
RETURN
Client Program
The following fragment of a BCI client program RESIGNATION calls the DELEMP
subroutine as a procedure, asking it to delete an employee but providing an incorrect
employee number (the same could be done with a UCI client program):
.
.
.
EMPNO = 555
ST = SQLExecDirect(HSTMT, "CALL DELEMP (":EMPNO:")")
IF ST <> 0 THEN
ERST =
SQLError(SQL.NULL.HENV,SQL.NULL.HDBC,HSTMT,STATE,CODE,MSG)
PRINT "SQLSTATE = ":STATE:", UniVerse error code = ":CODE:",
Error text ="
PRINT MSG
END
.
.
.
Sample Output
When the client program runs, output such as the following appears on the terminal
screen:
>RUN BP RESIGNATION
SQLSTATE = S1000, UniVerse error code = 950681, Error text =
[Ardent][SQL Client][UNIVERSE]Employee 555 does not exist
6-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch6
3/12/10
SQLNumResultCols
SQLDescribeCol
SQLColAttributes
SQLBindCol
SQLFetch
If a procedure fetches some of the rows in a SELECT’s result set and then returns to
the calling client application, the remaining rows (but not the fetched rows) are
available for the client to fetch.
If a procedure executes an SQL SELECT, fetches some rows and decides not to
return the remaining rows to the client, it should close the @HSTMT variable:
It is also necessary to close @HSTMT if the procedure wants to execute another SQL
statement using @HSTMT. Closing @HSTMT discards any pending results and
reinitializes the cursor associated with @HSTMT.
At the time a procedure exits, if @HSTMT has been closed and not reused, and if
SetDiagnostics has not been issued, a print result set is returned to the caller. If the
procedure executes no PRINT statements, the print result set contains no rows.
Ensure that both the procedure and the calling client application check the
status returned by each SQL Client Interface function call
(SQLExecDirect, SQLFetch, and so on).
Comment out the SQL Client Interface function calls in the procedure, or
close @HSTMT before exiting, so that the print results are returned to the
client; if necessary, add diagnostic PRINT statements to the procedure
program.
Debug UniVerse BASIC programs and subroutines by running them
directly, before calling them from a client application.
6-16
5Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLNumResultCols . . . . . . . . . . . . . . . . . . 7-71
SQLParamOptions . . . . . . . . . . . . . . . . . . 7-73
SQLPrepare . . . . . . . . . . . . . . . . . . . . 7-77
SQLRowCount . . . . . . . . . . . . . . . . . . . 7-80
SQLSetConnectOption . . . . . . . . . . . . . . . . . 7-82
SQLSetParam . . . . . . . . . . . . . . . . . . . . 7-88
SQLSpecialColumns. . . . . . . . . . . . . . . . . . 7-89
SQLStatistics . . . . . . . . . . . . . . . . . . . . 7-94
SQLTables . . . . . . . . . . . . . . . . . . . . . 7-99
SQLTransact . . . . . . . . . . . . . . . . . . . . 7-102
This chapter describes the SQL Client Interface functions in alphabetical order. The
following table lists the SQL Client Interface functions according to how they are
used.
Category Function
Initializing SQLAllocEnv
SQLAllocConnect
SQLSetConnectOption
SQLConnect
SQLAllocStmt
SQLPrepare
Category Function
Disconnecting SQLFreeStmt
SQLCancel
SQLDisconnect
SQLFreeConnect
SQLFreeEnv
Functions and Their Uses
The syntax diagram for each function includes the function name and any applicable
input, output, and return variables. For example:
You must call the SQLAllocEnv function before you use any other SQL Client
Interface function.
7-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Variable Names
In the previous syntax diagram, status is a return variable that the function returns
upon completion. bci.env is an input variable whose value is provided by a previous
function call. connect.env is an output variable containing a value output by the
function. Names of return variables, input variables, and output variables are user-
defined.
Return Values
SQL Client Interface functions return a value to the status variable. Return values are
the following:
100 SQL.NO.DATA.FOUND All rows from the result set were fetched
(SQLFetch), or no error to report
(SQLError).
Status Return Values
7-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Error Codes
Any SQL Client Interface function call can generate errors. Use the SQLError
function after any other function call for which the returned status indicates an error
condition. For a list of SQL Client Interface error codes, see Appendix C, “Error
Codes.”
ClearDiagnostics
ClearDiagnostics clears diagnostics from the SQL diagnostics area.
Syntax
status = ClearDiagnostics ( )
Return Values
0 Success
Description
Use ClearDiagnostics in a procedure to clear any diagnostics from the SQL
diagnostics area associated with @HSTMT. This removes any errors set by the
procedure, allowing the procedure to return SQL.SUCCESS and a result to the
calling program. No warning or error text is returned.
ClearDiagnostics 7-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
GetDiagnostics
GetDiagnostics returns the current warning or error text from the SQL diagnostics
area.
Syntax
error = GetDiagnostics ( )
Return Value
Return Value Description
error The text of the pending error. If none is set, an empty string is returned.
GetDiagnostics Return Value
Description
Use GetDiagnostics in a procedure to return the current error text associated with
@HSTMT.This text is the same as what would be returned to the output variable
error by SQLError. The error text is removed from the SQL diagnostics area.
When an SQL statement that uses @HSTMT returns anything other than
SQL.SUCCESS, the diagnostic information is associated with @HSTMT. This
information comprises the SQLSTATE, the native error number, and the warning or
error text.
You can use SQLError and GetDiagnostics to examine and clear this information. If
multiple diagnostics are available, you need to call these functions continually until
you have examined and cleared all diagnostics.
SetDiagnostics
SetDiagnostics adds an error to the SQL diagnostics area associated with
@HSTMT.This text is available to the SQLError and GetDiagnostics functions.
Syntax
status = SetDiagnostics (text)
Input Variable
Input Variable Description
Return Values
Return Value Description
0 Success
Description
A procedure can use SetDiagnostics to return an error message to the SQLExecute
or SQLExecDirect function that called the procedure.
SetDiagnostics 7-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
On exiting an SQL procedure, if an error has been set in the SQL diagnostics area
associated with @HSTMT, the procedure returns SQL.ERROR to the SQLExecute
or SQLExecDirect function that called it. The caller can then invoke SQLError or
GetDiagnostics to determine the SQLSTATE, native error number, and the error text.
The error text is stored in the SQL diagnostics area associated with @HSTMT and
remains available until the next programmatic SQL statement is executed.
Example
In the following example, the main program calls an SQL procedure named
GivePctRaise to give a 25% raise to employee 12345:
STATUS = SQLExecDirect (HSTMT, "call GivePctRaise(12345,25)")
The main program checks the status of the called procedure and reports any errors:
IF STATUS # SQL.SUCCESS THEN GOSUB SHOW.ERR
.
.
.
SHOW.ERR
PRINT 'Error from server.'
PRINT 'Status is ':STATUS
STATUS = SQLError(SQL.NULL.HENV, SQL.NULL.HDBC, HSTMT,
SQLSTATE, NATIVE, TEXT)
PRINT 'SQLSTATE is ':SQLSTATE
PRINT 'Native error is ':NATIVE
PRINT 'Error text is: ':TEXT
RETURN
SQLAllocConnect
SQLAllocConnect allocates and initializes a connection environment in an SQL
Client Interface environment.
Syntax
status = SQLAllocConnect (bci.env, connect.env)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
SQLAllocConnect 7-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLAllocConnect Return Values
Description
Use this function to create a connection environment to connect to a particular data
source. One SQL Client Interface environment can have several connection
environments, one for each data source. The function stores the internal
representation of the connection environment in the connect.env variable.
BASIC programs running locally on a UniVerse server (localuv) can use the
@variable @HDBC to refer directly to the connection environment. They do not
need to allocate one.
Note: Use the connection environment variable only in SQL Client Interface calls
that require it. Using it improperly can cause a run-time error and break
communication with the data source.
SQLAllocEnv
SQLAllocEnv creates an SQL Client Interface environment in which to execute SQL
Client Interface calls.
Syntax
status = SQLAllocEnv (bci.env)
Output Variable
The following table describes the output variable.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
SQLAllocEnv Return Values
Description
Use this function to allocate memory for an SQL Client Interface environment. The
function stores the address in the bci.env variable. SQLAllocEnv must be the first
SQL Client Interface call issued in any application.
You can allocate more than one SQL Client Interface environment.
SQLAllocEnv 7-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
BASIC programs running locally on a UniVerse server (localuv) can use the
@variable @HENV to refer directly to the SQL Client Interface environment. They
do not need to allocate one.
Note: Use the SQL Client Interface environment variable only in SQL Client
Interface calls that require it. Using it in any other context causes a run-time error
or breaks communication with the data source.
SQLAllocStmt
SQLAllocStmt creates an SQL statement environment in which to execute SQL
statements.
Syntax
status = SQLAllocStmt (connect.env, statement.env)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
SQLAllocStmt 7-16
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLAllocStmt Return Values
Description
Use this function to allocate memory for an SQL statement environment.
BASIC programs running locally on a UniVerse server (localuv) can use the
@variable @HSTMT to refer directly to the SQL statement environment. They do
not need to allocate one.
Note: Use the SQL statement environment variable only in SQL Client Interface calls
that require it. Using it in any other context causes a run-time error or breaks
communication with the data source.
SQLBindCol
SQLBindCol tells the system where to return column results when an SQLFetch call
is issued to retrieve the next row of data.
Syntax
status = SQLBindCol (statement.env, col#, data.type, column)
Input Variables
The following table describes the input variables.
col# Column number of result data, starting at 1. This value must be from
1 to the number of columns returned in an operation.
data.type BASIC data type into which to convert the incoming data. Possible
values are the following:
column Variable that will contain column results obtained with SQLFetch.
SQLBindCol Input Variables
SQLBindCol 7-18
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLBindCol Return Values
Description
Use this function to tell the SQL Client Interface where to return the results of an
SQLFetch call. SQLBindCol defines the name of the variable (column) to contain
column results retrieved by SQLFetch, and specifies the data conversion (data.type)
on the fetched data. SQLBindCol has no effect until SQLFetch is used.
Normally you call SQLBindCol once for each column of data in the result set. When
SQLFetch is issued, data is moved from the result set at the data source and put into
the variables specified in the SQLBindCol call, overwriting existing variable
contents.
Data is converted from the SQL data type at the data source to the BASIC data type
requested by the SQLBindCol call, if possible. If data cannot be converted to
data.type, an error occurs. For information about data conversion types, see
Appendix A, “Data Conversion.”
Values are returned only for bound columns. Unbound columns are ignored and are
not accessible. For example, if a SELECT command returns three columns, but
SQLBindCol was called for only two columns, data from the third column is not
accessible to your program. If you bind more variables than there are columns in the
result set, an error is returned. If you bind no columns and an SQLFetch is issued,
the cursor advances to the next row of results.
You need not use SQLBindCol with SQL statements that do not produce result sets.
Note: You cannot fetch raw multivalued data (that is, data from a column whose data
type is SQL.BINARY, SQL.VARBINARY, or SQL.LONGVARBINARY) from a
UniVerse data source unless you use dynamic normalization (see the UniVerse SQL
Reference).
SQLBindCol 7-20
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLBindParameter
SQLBindParameter specifies where to find values for input parameter markers
when an SQLExecute or SQLExecDirect call is issued. For output parameter
markers, SQLBindParameter specifies where to find the return value of a called
procedure.
Syntax
status = SQLBindParameter ( statement.env, mrk#, data.type, sql.type, prec, scale,
param [ , param.type ] )
Input Variables
The following table describes the input parameters.
mrk# Number of the parameter marker in the SQL statement this call refers to.
Parameter markers in the SQL statement are numbered left to right
starting at 1.
data.type BASIC data type to bind to the parameter. data.type must be one of the
following:
sql.type SQL data type to which the BASIC variable is converted. For
information about converting BASIC data to SQL data types, see
Appendix A, “Converting BASIC Data to SQL Data.”
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLBindParameter Return Values
SQLBindParameter 7-22
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Description
Parameter markers are placeholders in SQL statements. Input parameter markers let
a program send user-defined values with the SQL statement when an SQLExecute
or SQLExecDirect call is executed repeatedly. Output parameter markers receive
values returned from a called procedure. The placeholder character is ? (question
mark). For more information about parameter markers, see Using Parameter Markers
in SQL Statements in Chapter 4, “Using the SQL Client Interface.”
SQLBindParameter tells the system where to find the variables to substitute for
parameter markers in the SQL statement and how to convert the data before sending
it to the data source. You need to do only one SQLBindParameter for each
parameter marker in the SQL statement, no matter how many times the statement is
to be executed.
If you want to load 1000 rows, you need issue only three SQLBindParameter calls,
one for each question mark.
If you use SQL.B.INTDATE, the SQL Client Interface assumes the program variable
holds a date in UniVerse internal date format and uses the DATEFORM conversion
string to convert the internal date to an external format as required by the data source.
To set or change the DATEFORM conversion string, see the SQLSetConnectOption
function. For details about date and time conversions, see Appendix A, “Data
Conversion.”
SQLBindParameter uses the value of prec only for the following SQL data types:
SQL.CHAR
SQL.VARCHAR
SQL.LONGVARCHAR
SQL.WCHAR
SQL.WVARCHAR
SQL.WLONGVARCHAR
SQL.BINARY
SQL.VARBINARY
SQL.LONGVARBINARY
SQL.NUMERIC
SQL.DECIMAL
For all other data types, the extended parameters DBLPREC, FLOATPREC, and
INTPREC determine the maximum length for strings representing double-precision
numbers, floating-point numbers, and integers.
SQLBindParameter 7-24
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLCancel
SQLCancel cancels the current SQL statement associated with an SQL statement
environment and discards any pending results.
Syntax
status = SQLCancel (statement.env)
Input Variable
The following table describes the input variable.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLCancel Return Values
Description
This function is equivalent to the SQLFreeStmt call with the SQL.CLOSE option. It
closes any open cursor associated with the SQL statement environment and discards
pending results at the data source.
It is good practice to issue SQLCancel when all results have been read from the data
source, even if the SQL statement environment will not be reused immediately for
another SQL statement. Issuing SQLCancel frees any locks that may be held at the
data source.
SQLCancel 7-26
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLColAttributes
SQLColAttributes returns information about the columns available in a result set
produced by an SQL SELECT statement.
Syntax
status = SQLColAttributes (statement.env, col#, col.attribute, text.var, num.var)
Input Variables
The following table describes the input variables.
col.attribute Attribute of the column that needs information. col.attribute values are
listed in the following tables. These values are defined in the ODBC.H
file. Appendix E, “The ODBC.H File,” lists the contents of the
ODBC.H file.
SQLColAttributes Input Variables
Output Variables
The following table describes the output variables.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLColAttributes Return Values
SQLColAttributes 7-28
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Description
Use this function to get information about a column. SQLColAttributes returns the
specific information requested by the value of col.attribute.
Some DBMSs (such as SYBASE) do not make column information available until
after the SQL statement is executed. In such cases, issuing an SQLColAttributes
call before executing the statement produces an error.
The SQL.SUCCESS.WITH.INFO return occurs when you issue the call for a column
that contains an unsupported data type or when text.var is truncated. The SQL data
type returned is SQL.BINARY (−2).
The following table lists the column attributes you can use with both UniVerse and
ODBC databases.
SQLColAttributes 7-30
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
When you are connected to an ODBC data source, calling SQLColAttributes with
one of the UniVerse-only column attributes returns a status of SQL.ERROR with
SQLSTATE set to S1091.
SQLColAttributes 7-32
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLColumns
SQLColumns returns a result set listing the columns matching the search patterns.
Syntax
status = SQLColumns (statement.env, schema, owner, tablename, columnname )
Input Variables
The following table describes the input variables.
Description
This function returns a result set in statement.env as a cursor of 12 columns
describing those columns found by the search pattern. As with SQLTables, the search
is done on the SQL catalog. This is a standard result set that can be accessed with
SQLFetch. The ability to obtain descriptions of columns does not imply that a user
has any privileges on those columns.
TABLE.SCHEMA VARCHAR(128)
OWNER INTEGER
TABLE.NAME VARCHAR(128)
COLUMN.NAME VARCHAR(128)
DATA.TYPE SMALLINT
TYPE.NAME VARCHAR(128)
NUMERIC.PRECISION INTEGER
CHAR.MAX.LENGTH INTEGER
NUMERIC.SCALE SMALLINT
NUMERIC.PREC.RADIX SMALLINT
NULLABLE SMALLINT
REMARKS VARCHAR(254)
Result Set Columns
The application is responsible for binding variables for the output columns and
fetching the results using SQLFetch.
SQLColumns 7-34
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLColumns Return Values
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
24000 Invalid cursor state. Results are still pending from the previous SQL
statement. Use SQLCancel to clear the results.
42000 Syntax error or access violation. This can be caused by a variety of reasons.
The native error code returned by the SQLError call indicates the specific
UniVerse error that occurred.
SQLColumns SQLSTATE Values
SQLConnect
SQLConnect connects to a data source.
Syntax
status = SQLConnect (connect.env, data.source, logon1, logon2)
Input Variables
The following table describes input variables.
data.source Data source name. For UniVerse data sources, this is the name of a
valid data source defined in the uvodbc.config file. For ODBC data
sources, this is the name of a data source specified by the data source
management program you are using.
logon2 For local and remote UniVerse servers, logon2 is ignored. For ODBC
data sources, this is typically the password for the remote database or
operating system.
SQLConnect Input Variables
For the specific information required for logon1 and logon2 when connecting to
ODBC data sources, see the configuration for the specific driver used.
SQLConnect 7-36
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLConnect Input Variables
Description
Use this function to connect to the data source specified by data.source. UniVerse
data sources must be defined in the configuration file. Use the logon1 and logon2
parameters to log on to the DBMS specified by data.source.
As of Release 9.4.1, if you are connecting to a UniVerse server running with NLS
enabled, you can use the SQLSetConnectOption call to specify the NLS locale
information (SQL_NLSLOCALE, and so forth).
Note: Certain combinations of clients and servers may not be able to transfer data
reliably because of a mismatch in the character mapping, locale settings, or both at
the client end. See “Connecting to a UniVerse Server with NLS Enabled” in Chapter
4, “Using the SQL Client Interface,”for more information.
A connection is established when the data source validates the user name and
authorization.
If you are connecting to a local UniVerse server (localuv), you connect directly to the
UniVerse schema or account you are currently logged on to. You need not use
SQLSetConnectOption to specify the user name and password.
SQLConnect 7-38
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLDescribeCol
SQLDescribeCol returns information about one column of a result set produced by
an SQL SELECT statement.
Syntax
status = SQLDescribeCol (statement.env, col#, col.name, sql.type, prec, scale, null)
Input Variables
The following table describes the input variables.
Output Variables
The following table describes the output variables.
sql.type SQL data type of the column, a numeric code defined in the ODBC.H
file. See Appendix E, “The ODBC.H File,” for more information.
SQLDescribeCol Output Variables
Return Values
The following table describes the return values.
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLDescribeCol Return Values
Description
Use this function to get information about the column described by col#.
The SQL.SUCCESS.WITH.INFO return occurs when you issue the call for a column
that contains an unsupported data type, or if col.name is truncated. The SQL data type
returned is SQL.BINARY (−2).
SQLDescribeCol 7-40
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLDisconnect
SQLDisconnect disconnects a connection environment from a data source.
Syntax
status = SQLDisconnect (connect.env)
Input Variable
The following table describes the input variable.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLDisconnect Return Values
Description
You cannot use SQLDisconnect within a transaction. An SQLDisconnect call
issued within a transaction returns SQL.ERROR, and sets SQLSTATE to 25000. You
must commit or roll back active transactions before disconnecting, and you must be
in autocommit mode. If there is no active transaction, SQLDisconnect frees all SQL
statement environments owned by this connection before disconnecting.
SQLDisconnect 7-42
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLError
SQLError returns error status information about one of the three environments you
use.
Syntax
status = SQLError (bci.env, connect.env, statement.env, sqlstate, dbms.code, error)
Input Variables
The following table describes the input variables.
Output Variables
Output
Variable Description
sqlstate SQLSTATE code. This code describes the SQL Client Interface Client
error associated with the environment passed. sqlstate is always a five-
character string. For a list of SQLSTATE codes and their meanings,
see Appendix C, “Error Codes.”
dbms.code Error code specific to the data source. dbms.code contains an integer
error code from the data source. If dbms.code is 0, the error was
detected by the SQL Client Interface. For the meanings of specific
error codes, see the documentation provided for the data source.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
100 SQL.NO.DATA.FOUND
SQLError Return Values
Description
Use SQLError when a function returns a status value other than SQL.SUCCESS or
SQL.INVALID.HANDLE. SQLError returns a value in sqlstate when the SQL
Client Interface detects an error condition. The dbms.code field contains information
from the data source that identifies the error.
SQLError 7-44
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Each environment type maintains its own error status. SQLError returns errors for
the rightmost nonnull environment. For example, to get errors associated with a
connection environment, specify input variables and constants in the following order:
To get errors associated with a particular SQL statement environment, specify the
following:
Since multiple errors can be returned for a variable, you should call SQLError until
it returns a status of SQL.NO.DATA.FOUND. This ensures that all errors are
reported.
For information about errors detected by the SQL Client Interface, see Appendix C,
“Error Codes.”
For information about errors detected by the SQL Client Interface, see Appendix C,
“Error Codes.”
For information about errors detected by the ODBC driver manager, see the
Microsoft ODBC 2.0 Programmer’s Reference and SDK Guide.
For information about errors detected by the data source, see the documentation
provided for the DBMS running on the data source.
SQLError 7-46
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLExecDirect
SQLExecDirect accepts an SQL statement or procedure call and delivers it to the
data source for execution. It uses the current values of any SQL statement parameter
markers.
Syntax
status = SQLExecDirect (statement.env, statement)
Input Variables
The following table describes the input variables.
argument Any valid keyword, literal, or other token you can use
in a UniVerse command line.
SQLExecDirect Input Variables
SQLExecDirect 7-48
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLExecDirect Return Values
Description
SQLExecDirect differs from SQLExecute in that it does not require a call to
SQLPrepare. SQLExecDirect prepares the SQL statement or procedure call
implicitly. Use SQLExecDirect when you do not need to execute the same SQL
statement or procedure repeatedly.
You can use parameter markers in the SQL statement or procedure call as long as you
have resolved each marker with an SQLBindParameter call. For information about
parameter markers, see “Using Parameter Markers in SQL Statements” in Chapter 4,
“Using the SQL Client Interface.”.
If the executed SQL statement or procedure produces a set of results, you must use
an SQLFreeStmt call with the SQL.CLOSE option before you execute another SQL
statement or procedure call using the same SQL statement environment. The
SQL.CLOSE option cancels any pending results still waiting at the data source.
Your application programs should not try to issue transaction control statements
directly to the data source (for instance, by issuing a COMMIT statement with
SQLExecDirect or SQLPrepare). Programs should use only BASIC transaction
control statements. The SQL Client Interface issues the correct combination of
transaction control statements and middleware transaction control function calls that
are appropriate for the DBMS you are using. Trying to use SQLExecDirect to
execute explicit transaction control statements on ODBC data sources can cause
unexpected results and errors.
If you execute a stored procedure or enter a command batch with multiple SELECT
statements, the results of only the first SELECT statement are returned.
SQLExecDirect 7-50
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLExecute
SQLExecute tells the data source to execute a prepared SQL statement or a called
procedure, using the current values of any parameter markers used in the statement.
Using SQLExecute with an SQLBindParameter call is the most efficient way to
execute a statement repeatedly, since the statement does not have to be parsed by the
data source each time it is issued.
Syntax
status = SQLExecute (statement.env)
Input Variable
The following table describes the input variable.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLExecute Return Values
Description
Use this function to repeatedly execute an SQL statement, using different values for
parameter markers. You must use an SQLPrepare call to prepare the SQL statement
before you can use SQLExecute. If the SQL statement specified in the SQLPrepare
call contains parameter markers, you must also issue an SQLBindParameter call for
each marker in the SQL statement before you use SQLExecute. After you load the
parameter marker variables with data to send to the data source, you can issue the
SQLExecute call. By setting new values in the parameter marker variables and
calling SQLExecute, new data values are sent to the data source and the SQL
statement is executed using those values.
If the SQL statement uses parameter markers, SQLExecute performs any data
conversions required by the SQLBindParameter call for the parameter markers. See
Appendix A, “Data Conversion,” for details.
If the SQL statement executed produces a set of results, you must use an
SQLFreeStmt call with the SQL.CLOSE option before you execute another SQL
statement using the same SQL statement environment. The SQL.CLOSE option
cancels any pending results still waiting at the data source.
Your application programs should not try to issue transaction control statements
directly to the data source (for instance, by issuing a COMMIT statement with
SQLExecDirect or SQLPrepare). Programs should use only BASIC transaction
control statements. The SQL Client Interface issues the correct combination of
transaction control statements and middleware transaction control function calls that
are appropriate for the DBMS you are using. Trying to use SQLExecute to execute
explicit transaction control statements on ODBC data sources can cause unexpected
results and errors.
SQLExecute 7-52
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLFetch
SQLFetch returns the next row of data from the result set pending at the data source.
Syntax
status = SQLFetch (statement.env)
Input Variable
The following table describes the input variable.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
1 SQL.SUCCESS.WITH.INFO
100 SQL.NO.DATA.FOUND
SQLFetch Return Values
SQLFetch 7-54
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Description
Use this function to retrieve the next row’s column values from the result set at the
data source and put them into the variables specified with SQLBindCol. SQLFetch
performs any required data conversions (see Appendix A, “Data Conversion,” for
details).
SQLFetch logically advances the cursor to the next row in the result set. Unbound
columns are ignored and are not available to the application. When no more rows are
available, SQLFetch returns a status of 100.
Your application must issue an SQLFetch call at the same transaction nesting level
(or deeper) as the corresponding SQLExecDirect or SQLExecute call. Also, an
SQLFetch call must be executed at the same transaction isolation level as the
SELECT statement that generates the data. If it does not, SQLFetch returns
SQL.ERROR and sets SQLSTATE to S1000.
Use SQLFetch only when a result set is pending at the data source.
SQLFreeConnect
SQLFreeConnect releases a connection environment and its resources.
Syntax
status = SQLFreeConnect (connect.env)
Input Variable
The following table describes the input variable.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLFreeConnect Return Values
Description
You must use SQLDisconnect to disconnect the connection environment from the
data source before you release the connection environment with SQLFreeConnect,
otherwise an error is returned.
SQLFreeConnect 7-56
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLFreeEnv
SQLFreeEnv releases an SQL Client Interface environment and its resources.
Syntax
status = SQLFreeEnv (bci.env)
Input Variable
The following table describes the input variable.
Input
Variable Description
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLFreeEnv
Description
You must use SQLFreeConnect to release all connection environments attached to
the SQL Client Interface environment before you release the SQL Client Interface
environment with SQLFreeEnv, otherwise an error is returned.
SQLFreeStmt
SQLFreeStmt frees some or all resources associated with an SQL statement
environment.
Syntax
status = SQLFreeStmt (statement.env, option)
Input Variable
The following table describes the input variable.
Option Description
SQL.CLOSE Closes any open cursor associated with the SQL statement
environment and discards pending results at the data source.
Using the SQL.CLOSE option cancels the current query. All
parameter markers and columns remain bound to the variables
specified in the SQLBindCol and SQLBindParameter calls.
SQLFreeStmt 7-58
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Options are defined in the ODBC.H file. See Appendix E, “The ODBC.H File,” for
more information.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLFreeStmt Return Values
Description
Use this function at the end of processing to free resources used by the SQL statement
environment.
If your program uses the same SQL statement environment to execute different SQL
statements, use SQLFreeStmt with the SQL.DROP option, then use SQLAllocStmt
to reallocate a new SQL statement environment. This unbinds all bound columns and
resets all parameter marker variables.
It is good practice to issue SQLFreeStmt with the SQL.CLOSE option when all
results have been read from the data source, even if the SQL statement environment
will not be reused immediately for another SQL statement. Issuing SQLFreeStmt
with the SQL.CLOSE option frees any locks that may be held at the data source.
SQLGetInfo
SQLGetInfo returns general information about the ODBC driver and the data
source.
Syntax
status = SQLGetInfo (connect.env, info.type, info.value)
Input Variables
The following table describes the input variables.
info.type The specific information requested. For a list of values, see the
following tables.
SQLGetInfo Input Variables
Output Variable
The following table describes the output variable.
Output
Variable Description
Description
This function supports all of the possible requests for information defined in the
ODBC 2.0 specification. The #defines for info.type are contained in the ODBC.H
include file. In addition, SQLGetInfo also returns NLS information from UniVerse
data sources.
SQLGetInfo 7-60
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Driver Information
SQL.ACTIVE.CONNECTIONS SQL.DRIVER.VER
SQL.ACTIVE.STATEMENTS SQL.FETCH.DIRECTION
SQL.DATA.SOURCE.NAME SQL.FILE.USAGE
SQL.DRIVER.HDBC SQL.GETDATA.EXTENSIONS
SQL.DRIVER.HENV SQL.LOCK.TYPES
SQL.DRIVER.HLIB SQL.ODBC.API.CONFORMANCE
SQL.DRIVER.HSTMT SQL.ODBC.SAG.CLI.CONFORMANCE
SQL.DRIVER.NAME SQL.ODBC.VER
SQL.DRIVER.ODBC.VER SQL.POS.OPERATIONS
SQL.ROW.UPDATES SQL.SERVER.NAME
SQL.SEARCH.PATTERN.ESCAPE
SQL.DATABASE.NAME SQL.DBMS.VER
SQL.DBMS.NAME
SQL.ACCESSIBLE.PROCEDURES SQL.OWNER.TERM
SQL.ACCESSIBLE.TABLES SQL.PROCEDURE.TERM
SQL.BOOKMARK.PERSISTENCE SQL.QUALIFIER.TERM
ODBC info.type Values
SQL.CONCAT.NULL.BEHAVIOR SQL.SCROLL.CONCURRENCY
SQL.CURSOR.COMMIT.BEHAVIOR SQL.SCROLL.OPTIONS
SQL.DATA.SOURCE.READ.ONLY SQL.STATIC.SENSITIVITY
SQL.DEFAULT.TXN.ISOLATION SQL.TABLE.TERM
SQL.MULT.RESULT.SETS SQL.TXN.CAPABLE
SQL.MULTIPLE.ACTIVE.TXN SQL.TXN.ISOLATION.OPTION
SQL.NEED.LONG.DATA.LEN SQL.USER.NAME
SQL.NULL.COLLATION
Supported SQL
SQL.ALTER.TABLE SQL.ODBC.SQL.OPT.IEF
SQL.COLUMN.ALIAS SQL.ORDER.BY.COLUMNS.IN.SELECT
SQL.CORRELATION.NAME SQL.OUTER.JOINS
SQL.EXPRESSIONS.IN.ORDER.BY SQL.OWNER.USAGE
SQL.GROUP.BY SQL.POSITIONED.STATEMENTS
SQL.IDENTIFIER.CASE SQL.PROCEDURES
SQL.IDENTIFIER.QUOTE.CHAR SQL.QUALIFIER.LOCATION
SQL.KEYWORDS SQL.QUALIFIER.NAME.SEPARATOR
SQL.LIKE.ESCAPE.CLAUSE SQL.QUALIFIER.USAGE
SQL.NON.NULLABLE.COLUMNS SQL.QUOTED.IDENTIFIER.CASE
SQL.ODBC.SQL.CONFORMANCE SQL.SPECIAL.CHARACTERS
SQL.SUBQUERIES SQL.UNION
SQL Limits
SQL.MAX.BINARY.LITERAL.LEN SQL.MAX.OWNER.NAME.LEN
ODBC info.type Values
SQLGetInfo 7-62
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQL.MAX.CHAR.LITERAL.LEN SQL.MAX.PROCEDURE.NAME.LEN
SQL.MAX.COLUMN.NAME.LEN SQL.MAX.QUALIFIER.NAME.LEN
SQL.MAX.COLUMNS.IN.GROUP.BY SQL.MAX.ROW.SIZE
SQL.MAX.COLUMNS.IN.ORDER.BY SQL.MAX.ROW.SIZE.INCLUDES.LONG
SQL.MAX.COLUMNS.IN.INDEX SQL.MAX.STATEMENT.LEN
SQL.MAX.COLUMNS.IN.SELECT SQL.MAX.TABLE.NAME.LEN
SQL.MAX.COLUMNS.IN.TABLE SQL.MAX.TABLES.IN.SELECT
SQL.MAX.CURSOR.NAME.LEN SQL.MAX.USER.NAME.LEN
SQL.MAX.INDEX.SIZE
SQL.CONVERT.FUNCTIONS SQL.TIMEDATE.ADD.INTERVALS
SQL.NUMERIC.FUNCTIONS SQL.TIMEDATE.DIFF.INTERVALS
SQL.STRING.FUNCTIONS SQL.TIMEDATE.FUNCTIONS
SQL.SYSTEM.FUNCTIONS
Conversion Information
SQL.CONVERT.BIGINT SQL.CONVERT.LONGVARCHAR
SQL.CONVERT.BINARY SQL.CONVERT.NUMERIC
SQL.CONVERT.BIT SQL.CONVERT.REAL
SQL.CONVERT.CHAR SQL.CONVERT.SMALLINT
SQL.CONVERT.DATE SQL.CONVERT.TIME
SQL.CONVERT.DECIMAL SQL.CONVERT.TIMESTAMP
SQL.CONVERT.DOUBLE SQL.CONVERT.TINYINT
ODBC info.type Values
SQL.CONVERT.FLOAT SQL.CONVERT.VARBINARY
SQL.CONVERT.INTEGER SQL.CONVERT.VARCHAR
SQL.CONVERT.LONGVARBINARY
ODBC info.type Values
SQL.UVNLS.FIELD.MARK SQL.UVNLS.LC.NUMERIC
SQL.UVNLS.ITEM.MARK SQL.UVNLS.LC.TIME
SQL.UVNLS.MAP SQL.UVNLS.SQL.NULL
SQL.UVNLS.LC.ALL SQL.UVNLS.SUBVALUE.MARK
SQL.UVNLS.LC.COLLATE SQL.UVNLS.TEXT.MARK
SQL.UVNLS.LC.CTYPE SQL.UVNLS.VALUE.MARK
SQL.UVNLS.LC.MONETARY
UniVerse NLS info.type Values
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
SQLGetInfo Return Values
SQLGetInfo 7-64
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return
Value Description
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLGetInfo Return Values (Continued)
SQLGetTypeInfo
SQLGetTypeInfo returns information about an SQL on the data source. You can use
SQLGetTypeInfo only against ODBC data sources.
Syntax
status = SQLGetTypeInfo (statement.env, sql.type)
Input Variables
The following table describes the input variables.
SQL.B.BINARY SQL.LONGVARCHAR
SQL.BIGINT SQL.NUMERIC
SQL.BINARY SQL.REAL
SQL.BIT SQL.SMALLINT
SQL.C.BINARY SQL.TIME
SQL.CHAR SQL.TIMESTAMP
SQL.DATE SQL.TINYINT
SQL.DECIMAL SQL.VARBINARY
SQL.DOUBLE SQL.VARCHAR
SQL.FLOAT SQL.WCHAR
SQL.INTEGER SQL.WLONGVARCHAR
SQL.LONGVARBINARY SQL.WVARCHAR
SQLGetTypeInfo Input Variables
SQLGetTypeInfo 7-66
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Description
SQLGetTypeInfo returns a standard result set ordered by DATA.TYPE and
TYPE.NAME. The following table lists the columns in the result set. For more
detailed information about data type information, see the Microsoft ODBC 2.0
Programmer’s Reference and SDK Guide.
SEARCHABLE Smallint How the WHERE clause uses the data type.
Returns one of the following:
SQL.UNSEARCHABLE if data type cannot be
used
SQL.LIKE.ONLY if data type can be used only
with the LIKE predicate
SQL.ALL.EXCEPT.LIKE if data type can be
used with all comparison operators except
LIKE
SQL.SEARCHABLE if data type can be used
with any comparison operator
UNSIGNED.ATTRIBUTE
SQLGetTypeInfo 7-68
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLGetTypeInfo Return Values
SQLNumParams
SQLNumParams returns the number of parameters in an SQL statement.
Syntax
status = SQLNumParams (statement.env, parameters)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
Description
Use this function after preparing or executing an SQL statement or procedure call to
find the number of parameters in an SQL statement. If the statement associated with
statement.env contains no parameters, parameters is set to 0.
SQLGetCursorName 7-70
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLNumParams Return Values
SQLNumResultCols
SQLNumResultCols returns the number of columns in a result set.
Syntax
status = SQLNumResultCols (statement.env, cols)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
Output
Variable Description
SQLNumResultCols 7-72
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLNumResultCols Return Values
Description
Use this function after executing an SQL statement to find the number of columns in
the result set. If the executed statement was not a SELECT statement or a called
procedure that produced a result set, the number of result columns returned is 0.
Use this function when the number of columns to be bound to application variables
is unknown—as, for example, when your program is processing SQL statements
entered by users.
SQLParamOptions
SQLParamOptions lets applications specify an array of values for each parameter
assigned by SQLBindParameter.
Syntax
status = SQLParamOptions (statement.env, option, value)
Variables
The following table describes the SQLParamOptions variables.
Variable Description
SQL.PARAMOPTIONS.SET
value is an input variable containing the number of rows to process. It
can be an integer from 1 through 1024.
SQL.PARAMOPTIONS.READ
value is an output variable containing the number of parameter rows
processed by SQLExecDirect or SQLExecute. As each set of
parameters is processed, value is updated to the current row number. If
SQLExecDirect or SQLExecute encounters an error, value
contains the number of the row that failed.
SQLParamOptions Variables
SQLParamOptions 7-74
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLParamOptions Return Values
Description
The ability to specify multiple values for a set of parameters is useful for bulk inserts
and other work requiring the data source to process the same SQL statement multiple
times with various parameter values. An application can, for example, specify twenty
values for each parameter associated with an INSERT statement, then execute the
INSERT statement once to perform the twenty insertions.
You can use SQLParamOptions before or after you issue SQLBindParameter calls.
You need only one SQLParamOptions call with SQL.PARAMOPTIONS.SET, no
matter how many parameters are bound.
When the SQL statement is executed, all variables are checked, data is converted
when necessary, and all values in the set are verified to be appropriate and within the
bounds of the marker definition. Values are then copied to low-level structures
associated with each parameter marker. If a failure occurs while the values are being
checked, SQLExecDirect or SQLExecute returns SQL.ERROR, and value contains
the number of the row where the failure occurred.
INSERT
UPDATE
DELETE
Example
This example shows how you might use SQLParamOptions to load a simple table.
Table TAB1 has two columns: an integer column and a CHAR(30) column.
1 $include UNIVERSE.INCLUDE ODBC.H
arrsize = 20
dim p1(arrsize)
dim p2(arrsize)
SQLINS1 = "INSERT INTO TAB1 VALUES(?,?)"
rowindex = 0
status = SQLAllocEnv(henv)
status = SQLAllocConnect(henv, hdbc)
status = SQLConnect(hdbc, "odbcds", "dbuid", "dbpwd")
status = SQLAllocStmt(hdbc, hstmt)
SQLParamOptions 7-76
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
stexec = SQLExecute(hstmt)
status = SQLParamOptions(hstmt, SQL.PARAMOPTIONS.READ,
rowindex)
SQLPrepare
SQLPrepare passes an SQL statement or procedure call to the data source in order
to prepare it for execution by SQLExecute.
Syntax
status = SQLPrepare (statement.env, statement)
Input Variables
The following table describes the input variables.
SQLPrepare 7-78
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
argument Any valid keyword, literal, or other token you can use
in a UniVerse command line.
SQLPrepare Input Variables (Continued)
Return Values
The following table describes the return values.
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLPrepare Return Values
Description
Use this function to deliver either an SQL statement or a call to an SQL procedure to
the data source where it can prepare to execute the passed SQL statement or the
procedure. The application subsequently uses SQLExecute to tell the data source to
execute the prepared SQL statement or procedure.
What happens when the data source executes the SQLPrepare call depends on the
data source. In many cases the data source parses the SQL statement and generates
an execution plan that allows rapid, efficient execution of the SQL statement.
Use SQLPrepare and SQLExecute functions when you are issuing SQL statements
or calling a procedure repeatedly. You can supply values to a prepared INSERT or
UPDATE statement and issue an SQLExecute call each time you change the values
of parameter markers. SQLExecute sends the current values of the parameter
markers to the data source and executes the prepared SQL statement or procedure
with the current values.
Note: Before you issue an SQLExecute call, all parameter markers in the SQL
statement or procedure call must be defined using an SQLBindParameter call,
otherwise SQLExecute returns an error.
SQLPrepare 7-80
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLRowCount
SQLRowCount returns the number of rows changed by UPDATE, INSERT, or
DELETE statements, or by a called procedure that executes one of these statements.
Syntax
status = SQLRowCount (statement.env, rows)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLRowCount Return Values
Description
Statements such as GRANT and CREATE TABLE, which do not update rows in the
database, return 0 in rows.
For a SELECT statement, a 0 row count is always returned, unless the SELECT
statement includes the TO SLIST clause. In that case, SQLRowCount returns the
number of rows in the select list.
The value of rows returned after executing a stored procedure at the data source may
not be accurate. It is accurate for a single UPDATE, INSERT, or DELETE statement.
SQLRowCount 7-82
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLSetConnectOption
SQLSetConnectOption controls some aspects of the connection to a data source,
such as operating system login information and whether empty string data is returned
as null values.
Syntax
status = SQLSetConnectOption (connect.env, option, value)
Input Variables
The following table describes the input variable.
Options
option is one of the following, followed by a value:
Option Description
Option Description
SQLSetConnectOption 7-84
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Option Description
Use this option only with ODBC data sources, and only
after you connect to the data source.
SQL.TXN.VERSIONING No UniVerse
equivalent.
Option Description
SQLSetConnectOption 7-86
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLSetConnect Return Values
Description
The SQL.OS.UID and SQL.OS.PWD options let you specify user names and
passwords for the operating system of a UniVerse server.
Private Transactions
SQL.PRIVATE.TX.ON frees the connection from being managed by the UniVerse
transaction manager. When a connection is made private, the application can use the
SQL.AUTOCOMMIT option to put the connection into either autocommit mode or
manual commit mode. By default, private connections are in autocommit mode, in
which each SQL statement is treated as a separate transaction, committed after the
statement is executed.
You must return the connection to autocommit mode before using SQLDisconnect to
close the connection. You can do this in two ways:
Whenever you execute an SQL statement, a new transaction exists, which makes
setting the SQL.TXN.ISOLATION option illegal. If a transaction is active when the
SQL.TXN.ISOLATION.OPTION is set, the SQL Client Interface returns
SQL.ERROR and sets SQLSTATE to S1C00.
SQLSetConnectOption 7-88
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLSetParam
SQLSetParam has been superseded by SQLBindParameter.
SQLSpecialColumns
SQLSpecialColumns gets information about columns in a table. Use this function
only when you are connected to an ODBC data source.
Syntax
status = SQLSpecialColumns (statement.env, col.type, schema, owner, tablename,
IDscope, null)
Input Variables
The following table describes the input variables.
owner Name of the owner of the table. If a driver supports owners for
some table but not others, use an empty string for tables that do
not have owners.
IDScope Minimum required scope of the row ID. IDscope is one of the
following:
SQLSpecialColumns Input Variables
SQLSpecialColumns 7-90
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLSpecialColumns Return Values
Description
Results are returned as a standard result set ordered by SCOPE. The following table
lists the columns in the result set. The lengths of VARCHAR columns are maximums;
the actual lengths depend on the data source. To get the length of the
COLUMN.NAME column, use the SQL.MAX.COLUMN.NAME.LEN option of
the SQLGetInfo function.
SQLSpecialColumns 7-92
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Once the application gets values for SQL.BEST.ROWID, it can use these values to
reselect that row within the defined scope. The SELECT statement is guaranteed to
return either no rows or one row.
Columns returned for column type SQL.ROWVER let applications check if any
columns in a given row have been updated while the row was reselected using the
row ID.
If col.type, IDscope, or null specifies characteristics not supported by the data source,
SQLSpecialColumns returns a result set with no rows, and a subsequent call to
SQLFetch returns SQL.NO.DATA.FOUND.
For complete details about the SQLSpecialColumns function, see the Microsoft
ODBC 2.0 Programmer’s Reference and SDK Guide.
SQLSpecialColumns 7-94
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLStatistics
SQLStatistics gets a list of statistics about a single table and its indexes. Use this
function only when you are connected to an ODBC data source.
Syntax
status = SQLStatistics (statement.env, schema, owner, tablename, index.type,
accuracy)
Input Variables
The following table describes the input variables.
owner Name of the owner of the table. If a driver supports owners for some
table but not others, use an empty string for tables that do not have
owners.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLStatistics Return Values
Description
SQLStatistics returns information as a standard result set ordered by
NON.UNIQUE, TYPE, INDEX.QUALIFIER, INDEX.NAME, and
SEQ.IN.INDEX. The result set combines statistics for the table with statistics for
each index. The following table lists the columns in the result set.
Note: SQLStatistics might not return all indexes. For example, a driver might return
only the indexes in files in the current directory. Applications can use any valid index
regardless of whether it is returned by SQLStatistics.
SQLStatistics 7-96
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
The lengths of VARCHAR columns are maximums; the actual lengths depend on the
data source. Use SQLGetInfo to determine the actual lengths of the
TABLE.QUALIFIER, TABLE.OWNER, TABLE.NAME, and COLUMN.NAME
columns.
TABLE.OWNER Varchar(128) Name of the owner of the table. The null value
is returned if it is not applicable to the data
source. If a driver supports owners for some
tables but not others, it returns an empty string
for tables without owners.
SQLStatistics 7-98
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
NON.UNIQUE
INDEX.QUALIFIER
INDEX.NAME
SEQ.IN.INDEX
COLUMN.NAME
COLLATION
If CARDINALITY or PAGES are not available from the data source, the driver sets
them to NULL.
For complete details about the SQLStatistics function, see the Microsoft ODBC 2.0
Programmer’s Reference and SDK Guide.
SQLTables
SQLTables returns a result set listing the tables matching the search patterns. Use this
function only when you are connected to an ODBC data source.
Syntax
status = SQLTables (statement.env, schema, owner, tablename, type)
Input Variables
The following table describes the input variables.
SQLTables 7-100
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
Description
This function returns statement.env as a standard result set of five columns containing
the schemas, owners, names, types, and remarks for all tables found by the search.
The search criteria arguments can contain a literal, an SQL LIKE pattern, or be
empty. If a literal or LIKE pattern is specified, only values matching the pattern are
returned. If a criterion is empty, tables with any value for that attribute are returned.
owner cannot specify a LIKE pattern. You can access the result set with SQLFetch.
These five columns have the following descriptors:
TABLE.SCHEMA VARCHAR(128)
TABLE.OWNER VARCHAR(128)
TABLE.NAME VARCHAR(128)
TABLE.TYPE VARCHAR(128)
REMARKS VARCHAR(254)
empty string empty string empty string % Set of distinct table types
Search Criteria Combinations
The ability to obtain information about tables does not imply that you have any
privileges on those tables.
Return Values
The following table describes the return values.
Return
Value Description
0 SQL.SUCCESS
1 SQL.SUCCESS.WITH.INFO
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLTables Return Values
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
24000 Invalid cursor state. Results are still pending from the previous SQL
statement. Use SQLCancel to clear the results.
SQLTables 7-102
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLTransact
SQLTransact requests a COMMIT or ROLLBACK for all SQL statements
associated with a connection or all connections associated with an environment. Use
this function only when you are connected to an ODBC data source.
Syntax
status = SQLTransact (bci.env, connect.env, type)
Input Variables
The following table describes the input variables.
Description
This function provides the same transaction functions as the UniVerse BASIC
statements COMMIT, and ROLLBACK. When connect.env is a valid connection
environment with SQL.AUTOCOMMIT set to OFF, SQLTransact commits or rolls
back the connection.
If any action fails, SQL.ERROR is returned, and the user can determine which
connections failed by calling SQLError for each connection environment in turn.
Return Values
The following table describes the return values.
0 SQL.SUCCESS
-1 SQL.ERROR
-2 SQL.INVALID.HANDLE
SQLTransact Return Values
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLTransact 7-104
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Ch7
3/12/10
SQLSTATE Description
08007 The connection associated with the transaction failed during the execution
of the function. It cannot be determined if the requested operation
completed before the failure.
SQLTransact SQLSTATE Values (Continued)
Data Conversion
A
This appendix describes the UniVerse BASIC and ODBC SQL data
types you can specify with the SQLBindParameter and SQLBindCol
calls. It also explains how data is converted.
You use SQLBindCol to convert SQL data retrieved from the data
source, to a BASIC data type. You can specify that data retrieved from
the data source be stored locally as:
You can also specify SQL.B.DEFAULT. This lets the ODBC SQL data
type determine the BASIC data type to which to convert data from the
data source. The NULL data type requires no conversion.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
The following table shows the BASIC SQL Client Interface data types and their
UniVerse BASIC counterparts.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
The following table shows the ODBC SQL data types and their SQL definitions. You
can use these ODBC SQL data types when you connect to UniVerse data sources and
to ODBC data sources.
A-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
The following table lists ODBC SQL data types you can use when connected to
certain ODBC data sources. Do not use these data types when connected to a
UniVerse data source unless your connection uses UniVerse ODBC.
SQL.TINYINTc Signed integer from 0 through 255; unsigned integer from 128
through +127.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
A-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Both SQLExecute and SQLExecDirect calls check the data type and convert the data.
Data from locations indicated in SQLBindParameter must be one of the following:
Any other kind of data returns an error to the SQLExecute or SQLExecDirect call.
All data sent to UniVerse data sources is sent as character string data. Multivalued
data is sent to UniVerse data sources as multivalued dynamic arrays.
Note: You cannot send multivalued bit string values to a UniVerse data source,
because the UniVerse system delimiters cannot be recognized in a stream of raw data
bits.
When converting BASIC character string data to numeric SQL data types, all
numbers are rounded to 15 digits. The SQLSetConnectOption flag,
SQL.TRUNC.ROUND, is ignored.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
For ODBC data sources, precision is observed for the following ODBC SQL data
types:
SQL.CHARSQL.WCHAR
SQL.VARCHARSQL.WVARCHAR
SQL.LONGVARCHARSQL.WLONGVARCHAR
SQL.BINARYSQL.NUMERIC
SQL.VARBINARYSQL.DECIMAL
SQL.LONGVARBINARY
SQL.DECIMAL
SQL.NUMERIC
All data sent to ODBC data sources is checked by the ODBC driver and database
engine. Thus, conversion failures can be detected either by the BASIC SQL Client
Interface, by the ODBC driver, or by the underlying DBMS.
SQL.CHARSQL.WCHAR
SQL.VARCHARSQL.WVARCHAR
SQL.LONGVARCHARSQL.WLONGVARCHAR
When the data is a BASIC subroutine, the subroutine name is used as the string value.
A-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQL.BITSQL.BINARY
SQL.VARBINARY
SQL.LONGVARBINARY
For SQL.BIT binding, the application should use only the values 0 and 1. ODBC
drivers vary as to how they handle other values. Some may return SQL.ERROR,
others may return SQL.SUCCESS.WITH.INFO and deliver the integer part of a
fractional number.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
If the number of significant digits (digits to the left of the decimal point) is greater
than the specified precision, SQL.ERROR is returned with an SQLSTATE of 22003.
If the number of insignificant digits (digits to the right of the decimal point) is greater
than the column’s defined scale, SQL.SUCCESS.WITH.INFO is returned with an
SQLSTATE of 01004, indicated that fractional truncation has occurred.
SQL.INTEGERSQL.SMALLINT
SQL.BIGINTSQL.TINYINT
A-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Some data sources such as SYBASE treat the TINYINT data type as unsigned, others
treat it as signed. Use SQLGetTypeInfo to determine whether the type is signed or
unsigned.
BASIC to SQL.DATE
The SQLBindParameter call can contain SQL.B.BASIC or SQL.B.INTDATE as
the BASIC data type. If a BASIC string is a date in external format, use
SQL.B.BASIC. If the string is a date in internal format, use SQL.B.INTDATE.
If you specify a BASIC data type of SQL.B.INTDATE and the ODBC SQL data type
is not SQL.DATE, the BASIC SQL Client Interface returns an error and sets
SQLSTATE to 07006. If the date is invalid, the BASIC SQL Client Interface returns
SQL.ERROR and sets SQLSTATE to 22008.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
yyyy-mm-dd
yyyy-mm-dd
BASIC to SQL.TIME
The SQLBindParameter call can contain SQL.B.BASIC or SQL.B.INTTIME as the
BASIC data type. If the string is a time in external format (hh:mm:ss), use
SQL.B.BASIC. If the string is a time in internal format, use SQL.B.INTTIME.
All times in external format (SQL.B.BASIC) must be specified using the following
format:
[ h ] h: [ m ] m: [ s ] s
If the hour value is greater than 24, the value is divided by 24 and the remainder is
used for the hour. So 50:01:02 is equivalent to 02:01:02. The minutes and seconds
values must be from 0 to 59; if they are not, SQL.ERROR is returned and SQLSTATE
is set to 22008.
When sending times to a UniVerse data source, the MTS conversion code converts
times in external format to internal format.
If you specify a BASIC data type of SQL.B.INTTIME, the value is interpreted as the
number of seconds since midnight. The value should be from 0 (midnight) to 86399.
On UniVerse data sources, values outside this range can produce unusual results. On
ODBC data sources, if a value is outside this range, the BASIC SQL Client Interface
returns SQL.ERROR and sets SQLSTATE to 22008.
A-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Times in internal format (SQL.B.INTTIME) need no conversion when they are sent
to a UniVerse data source.
BASIC to SQL.TIMESTAMP
The TIMESTAMP data type is available only for ODBC data sources.
The SQLBindParameter call should contain SQL.B.BASIC as the BASIC data type
and SQL.TIMESTAMP as the SQL data type. The format for timestamp data is as
follows:
yyyy-mm-dd hh:mm:ss
Be sure to supply both parts of this string, because ODBC drivers vary in how they
handle a timestamp lacking a date or a time.
If either the date or the time is invalid, SQL.ERROR is returned and SQLSTATE is
set to 22008.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Use SQL.B.INTDATE only with the SQL types DATE and TIMESTAMP; use
SQL.B.INTTIME only with the SQL types TIME and TIMESTAMP. If you use them
with any other SQL type, the SQLFetch function returns SQL.ERROR and sets
SQLSTATE to 07006.
Unlike SQLBindParameter, which does not send truncated data to the data source,
the SQLFetch function associated with SQLBindCol delivers rounded or truncated
data to the BASIC program.
For the character string and bit string SQL data types, SQL.B.DEFAULT is
equivalent to using SQL.B.CHAR.
For the numeric SQL data types, SQL.B.DEFAULT is equivalent to
specifying SQL.B.NUMBER at the SQLBindCol call. Data is stored in
either integer or double form.
For UniVerse data sources, SQL.B.DEFAULT is always equivalent to
SQL.B.CHAR.
A-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
UniVerse files sometimes use an internal format to store DECIMAL and NUMERIC
data types. In such cases, the file dictionary contains a code that converts the stored
representation of the numbers into a format suitable for output. For example, a file
can store the number 123.45 as 12345. The file dictionary uses an MD2 conversion
to insert the decimal point when the number is retrieved. For data coming from the
data source, the BASIC program may have to use the ICONV function to convert
incoming data to the proper UniVerse internal storage format.
UniVerse servers return data to the client in a stripped external format. For example,
if a money column has a conversion code of MD22$, , the value $4.50 is stored as the
integer 450. The UniVerse server returns the value 4.50 to a bound column, which is
the correct numeric value in external format, stripped of any text-formatting symbols
such as $ (dollar sign) or , (comma).
SQL.CHAR
SQL.VARCHAR
SQL.LONGVARCHAR
SQL.WCHAR
SQL.WVARCHAR
SQL.WLONGVARCHAR
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQL.BINARY
SQL.VARBINARY
SQL.LONGVARBINARY
A-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Note: Multivalued data is passed through with value marks, but because the data is
passed as a bit string, the value marks cannot be distinguished as meaningful
delimiters. To fetch multivalued bit string data from a UniVerse data source, use
dynamic normalization (see the UniVerse SQL Reference).
SQL.DECIMAL
SQL.NUMERIC
SQL.SMALLINT
SQL.INTEGER
SQL.REAL
SQL.FLOAT
SQL.DOUBLE
Data returned from a UniVerse data source does not need to be converted. Space is
allocated and the string is stored in the BASIC datum. Trailing spaces are deleted.
Multivalued data is passed through with value marks.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Data returned from a UniVerse data source to SQL.B.DEFAULT does not need to be
converted. Space is allocated and the string is stored in the BASIC datum. Trailing
spaces are deleted. If the conversion results in an integer part loss, the BASIC SQL
Client Interface returns SQL.ERROR and sets SQLSTATE to 01004. If the
conversion results in a fractional part loss, SQL.ERROR is returned and SQLSTATE
is set to 22001.
You cannot convert any of these SQL data types to SQL.B.NUMBER. If you try,
SQLFetch generates SQL.ERROR and sets SQLSTATE to 07006.
A-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppA
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
yyyy-mm-dd
Times from both UniVerse and ODBC data sources are returned in the following
format:
hh:mm:ss
If the date or time is not valid, SQLFetch returns SQL.ERROR and sets SQLSTATE
to 22008.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
yyyy-mm-dd
hh:mm:ss
A-19
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Appendix
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Main Program
First the program includes the SQL Client Interface definitions from the ODBC.H
file:
* Include the ODBC definitions
form = "T##########"
dash = "----------"
Expect = ""
The program creates an ODBC environment and a connection environment. Use the
SQLSetConnectOption call to specify the operating system user name and password.
STATUS = SQLAllocEnv(DBCENV)
IF STATUS <> SQL.SUCCESS THEN STOP "Failed to allocate an ODBC
environment"
STATUS = SQLAllocConnect(DBCENV,CONENV)
IF STATUS <> SQL.SUCCESS THEN STOP "Failed to allocate a CONNECT
environment"
The next section gathers the name of the data source, the user name and password for
the server operating system, and information for the data source. The DBMS
information is often a user name and a password.
PRINT "Please enter the target data source ":
INPUT SOURCE
UID=""
PWD=""
gosub testodbc
if toodbc = 0
then
PRINT "Please enter the username for the server operating
system login ":
INPUT OSUID
PRINT "Please enter the operating system password for user
":OSUID:" ":
ECHO OFF
INPUT OSPWD
PRINT ""
ECHO ON
PRINT "Enter name or path of remote schema/account (hit return
if local)":
INPUT UID
PWD = ""
PRINT "";PRINT ""
B-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
After making the connection, the program creates some local UniVerse files and
loads them with data:
gosub CREATEFILES
gosub LOADFILES
The following lines create an SQL statement environment for executing SQL
statements:
Fn = "SQLAllocStmt"
STATUS = SQLAllocStmt(CONENV,STMTENV)
GOSUB CKCONENV
Next the program creates some SQL tables on the data source, then loads the tables
with data by reading records from UniVerse files:
gosub CREATETABLES
gosub LOADTABLES
After loading the SQL tables, the program reads them back and displays them:
gosub SELECTFILES
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
The following lines free up the statement, connection, and ODBC environments, and
exit the program:
Fn = "SQLFreeStmt"
STATUS = SQLFreeStmt(STMTENV, SQL.DROP)
GOSUB CKSTMTENV
Fn = "SQLDisconnect"
STATUS = SQLDisconnect(CONENV)
GOSUB CKCONENV
Fn = "SQLFreeConnect"
STATUS = SQLFreeConnect(CONENV)
GOSUB CKCONENV
Fn = "SQLFreeEnv"
STATUS = SQLFreeEnv(DBCENV)
IF STATUS <> SQL.SUCCESS THEN STOP "Failed to release ODBC
environment"
B-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EXECUTE CREATE.STAFF
PRINT ""
Now the program populates the dictionary with definitions that would have been put
in with the following SQL statement:
* CREATE TABLE SQLCOSTAFF (TYPE 2, MODULO 1, SEPARATION 1,
* EMPNUM CHAR(10) NOT NULL PRIMARY KEY,
* EMPNAME CHAR(10), EMPGRADE INTEGER, EMPCITY CHAR(15) );
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
NEXT I
WRITE REC TO STAFFVAR, ID
NEXT INDEX
CLOSE STAFFVAR
RETURN
B-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
*
* Setup data to insert into UniVerse tables and data source'
tables
*
DIM EMPDATA(5)
EMPDATA(1) = "E1":@FM:"Alice":@FM: 12:@FM:"Deale"
EMPDATA(2) = "E2":@FM:"Betty":@FM: 10:@FM:"Vienna"
EMPDATA(3) = "E3":@FM:"Carmen":@FM: 13:@FM:"Vienna"
EMPDATA(4) = "E4":@FM:"Don":@FM: 12:@FM:"Deale"
EMPDATA(5) = "E5":@FM:"Ed":@FM: 13:@FM:"Akron"
*
* Clear the files and then load them up
*
RETURN
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
* Drop table statements to alwasy drop the target table before re-
creating
* them.
* Now create the tables needed for testing on the host DBMS
RETURN
B-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ROWNUM = 0
Fn = "SQLBindParameter"
PRINT ""; PRINT "Setting values for the parameter markers"
Now the program opens the local UniVerse SQLCOSTAFF table, reads values from
it, puts the values into the SQLBindParameter variables, and executes the prepared
INSERT statement:
OPEN "SQLCOSTAFF" TO FILEVAR ELSE STOP "Failed to open SQLCOSTAFF
file"
SELECT FILEVAR
NEXTID:
ROWNUM = ROWNUM+1
READNEXT ID ELSE GOTO EOD1
READ REC FROM FILEVAR,ID ELSE STOP "Error reading local
SQLCOSTAFF file"
EMPNUM = ID
EMPNAME = REC<1>
GRADE = REC<2>
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
CITY = REC<3>
EOD1:
CLOSE FILEVAR
ROWNUM = 0
RETURN
B-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Fn = "SQLExecDirect"
STATUS = SQLExecDirect(STMTENV,SEL01)
GOSUB CKSTMTENV
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
COUNT = -1
IF STATUS EQ -2 THEN STOP "INVALID CONNECTION HANDLE"
IF STATUS NE 0
THEN
201*
ST = SQLERROR(-1,CONENV,-1,STATE,NATCODE,ERRTXT)
IF ST <> SQL.NO.DATA.FOUND
THEN
PRINT "****************************************"
COUNT = 1
IF Expect NE 0 AND STATE = Expect AND ST <>
SQL.NO.DATA.FOUND
THEN
PRINT "Allowed error of ":STATE:" returned for func ":Fn
GOTO 299
END
ELSE
PRINT "Status for ":Fn:" call is: ":STATUS
PRINT "SQLSTATE,NATCOD are:" : STATE:" ":NATCODE
PRINT "Error text is"
PRINT " " : ERRTXT
END
IF ST = SQL.SUCCESS THEN GOTO 201
END
IF STATUS = -1 AND COUNT = 1 THEN STOP "EXITING CKCONENV"
END
299*
IF STATUS <> 0 THEN PRINT
"****************************************"
RETURN
The second subroutine is used for calls issued when there is an SQL statement
environment:
CKSTMTENV:
IF STATUS EQ -2 THEN STOP "INVALID STATEMENT HANDLE"
B-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppB
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
THEN
PRINT "****************************************"
COUNT = 1
IF Expect NE 0 AND STATE = Expect AND ST <>
SQL.NO.DATA.FOUND
THEN
PRINT "Allowed error of ":STATE:" returned for func ":Fn
GOTO 399
END
ELSE
PRINT "Status for ":Fn:" call is: ":STATUS
PRINT "SQLSTATE,NATCOD are:" : STATE:" ":NATCODE
PRINT "Error text is "
PRINT " " : ERRTXT
END
IF ST = 0 THEN GOTO 301
END
IF STATUS = -1 AND COUNT = 1 THEN STOP "EXITING CKSTMTENV"
END
399*
IF STATUS <> 0 THEN PRINT
"****************************************"
RETURN
Error Codes
C
The following table lists the SQLSTATE values and the corresponding
messages they generate.
SQLSTATE Message
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLSTATE Message
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLSTATE Message
C-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppC
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLSTATE Message
UniVerse
Extended Parameters D
The following table lists data source and DBMS-type extended
parameters with their current default settings.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
D-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppD
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ODBCNone No
MAXLONGVARCHAR Yes
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
NLSLCMONETARY
D-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppD
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Transaction Parameters
D-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppD
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.ERROR TO
-1
EQU SQL.INVALID.HANDLE TO
-2
EQU SQL.NEED.DATA TO
99
EQU SQL.NO.DATA.FOUND TO
100
EQU SQL.SUCCESS TO
0
EQU SQL.SUCCESS.WITH.INFO TO
1
EQU SQL.NULL.HENV TO
-1
EQU SQL.NULL.HDBC TO
-1
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.NULL.HSTMT TO -1
EQU SQL.NULL.DATA TO -1
* SQLColAttributes defines
EQU SQL.COLUMN.COUNT TO 1
EQU SQL.COLUMN.NAME TO 2
EQU SQL.COLUMN.TYPE TO 3
EQU SQL.COLUMN.LENGTH TO 4
EQU SQL.COLUMN.PRECISION TO 5
EQU SQL.COLUMN.SCALE TO 6
EQU SQL.COLUMN.DISPLAYSIZE TO 7
EQU SQL.COLUMN.DISPLAY.SIZE TO 7
EQU SQL.COLUMN.NULLABLE TO 8
EQU SQL.COLUMN.UNSIGNED TO 9
EQU SQL.COLUMN.MONEY TO 10
EQU SQL.COLUMN.UPDATABLE TO 11
EQU SQL.COLUMN.AUTO.INCREMENT TO 12
EQU SQL.COLUMN.CASE.SENSITIVE TO 13
EQU SQL.COLUMN.SEARCHABLE TO 14
EQU SQL.COLUMN.TYPE.NAME TO 15
EQU SQL.COLUMN.TABLE.NAME TO 16
EQU SQL.COLUMN.OWNER.NAME TO 17
EQU SQL.COLUMN.QUALIFIER.NAME TO 18
EQU SQL.COLUMN.LABEL TO 19
EQU SQL.COLUMN.MULTIVALUED TO 1001
EQU SQL.COLUMN.FORMAT TO 1002
EQU SQL.COLUMN.CONVERSION TO 1003
EQU SQL.COLUMN.PRINT.RESULT TO 1004
EQU SQL.ATTR.READONLY TO 0
EQU SQL.ATTR.WRITE TO 1
EQU SQL.ATTR.READWRITE.UNKNOWN TO 2
EQU SQL.UNSEARCHABLE TO 0
EQU SQL.LIKE.ONLY TO 1
EQU SQL.ALL.EXCEPT.LIKE TO 2
EQU SQL.SEARCHABLE TO 3
* SQLSetConnectOption defines
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.AUTOCOMMIT.OFF TO 0
EQU SQL.AUTOCOMMIT.ON TO 1
EQU SQL.CLOSE TO 1
EQU SQL.DROP TO 2
EQU SQL.UNBIND TO 3
EQU SQL.RESET.PARAMS TO 4
EQU SQL.CHAR TO 1
EQU SQL.NUMERIC TO 2
EQU SQL.DECIMAL TO 3
EQU SQL.INTEGER TO 4
EQU SQL.SMALLINT TO 5
EQU SQL.FLOAT TO 6
EQU SQL.REAL TO 7
EQU SQL.DOUBLE TO 8
EQU SQL.DATE TO 9
EQU SQL.TIME TO 10
EQU SQL.TIMESTAMP TO 11
EQU SQL.VARCHAR TO 12
EQU SQL.LONGVARCHAR TO -1
EQU SQL.BINARY TO -2
E-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppE
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.VARBINARY TO -3
EQU SQL.LONGVARBINARY TO -4
EQU SQL.BIGINT TO -5
EQU SQL.TINYINT TO -6
EQU SQL.BIT TO -7
EQU SQL.WCHAR TO -8
EQU SQL.WVARCHAR TO -9
EQU SQL.WLONGVARCHAR TO -10
EQU NUM.SQL.TYPES TO 22
EQU SQL.CHAR.DSPSIZE TO 0
EQU SQL.VARCHAR.DSPSIZE TO 0
EQU SQL.DECIMAL.DSPSIZE TO 2
EQU SQL.NUMERIC.DSPSIZE TO 2
EQU SQL.SMALLINT.DSPSIZE TO 6
EQU SQL.INTEGER.DSPSIZE TO 11
EQU SQL.REAL.DSPSIZE TO 13
EQU SQL.FLOAT.DSPSIZE TO 22
EQU SQL.DOUBLE.DSPSIZE TO 22
EQU SQL.DATE.DSPSIZE TO 10
EQU SQL.TIME.DSPSIZE TO 8
EQU SQL.NO.NULLS TO 0
EQU SQL.NULLABLE TO 1
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.NULLABLE.UNKNOWN TO 2
EQU SQL.PARAM.INPUT TO 1
EQU SQL.PARAM.INPUT.OUTPUT TO 2
EQU SQL.PARAM.OUTPUT TO 4
EQU SQL.ACTIVE.CONNECTIONS TO 0
EQU SQL.ACTIVE.STATEMENTS TO 1
EQU SQL.DATA.SOURCE.NAME TO 2
EQU SQL.DRIVER.HDBC TO 3
EQU SQL.DRIVER.HENV TO 4
EQU SQL.DRIVER.HSTMT TO 5
EQU SQL.DRIVER.NAME TO 6
EQU SQL.DRIVER.VER TO 7
EQU SQL.FETCH.DIRECTION TO 8
EQU SQL.ODBC.API.CONFORMANCE TO 9
EQU SQL.ODBC.VER TO 10
EQU SQL.ROW.UPDATES TO 11
EQU SQL.ODBC.SAG.CLI.CONFORMANCE TO 12
EQU SQL.SERVER.NAME TO 13
EQU SQL.SEARCH.PATTERN.ESCAPE TO 14
EQU SQL.ODBC.SQL.CONFORMANCE TO 15
EQU SQL.DATABASE.NAME TO 16
EQU SQL.DBMS.NAME TO 17
EQU SQL.DBMS.VER TO 18
EQU SQL.ACCESSIBLE.TABLES TO 19
EQU SQL.ACCESSIBLE.PROCEDURES TO 20
EQU SQL.PROCEDURES TO 21
EQU SQL.CONCAT.NULL.BEHAVIOR TO 22
EQU SQL.CURSOR.COMMIT.BEHAVIOR TO 23
EQU SQL.CURSOR.ROLLBACK.BEHAVIOR TO 24
EQU SQL.DATA.SOURCE.READ.ONLY TO 25
EQU SQL.DEFAULT.TXN.ISOLATION TO 26
EQU SQL.EXPRESSIONS.IN.ORDERBY TO 27
EQU SQL.IDENTIFIER.CASE TO 28
EQU SQL.IDENTIFIER.QUOTE.CHAR TO 29
EQU SQL.MAX.COLUMN.NAME.LEN TO 30
EQU SQL.MAX.CURSOR.NAME.LEN TO 31
EQU SQL.MAX.OWNER.NAME.LEN TO 32
EQU SQL.MAX.PROCEDURE.NAME.LEN TO 33
EQU SQL.MAX.QUALIFIER.NAME.LEN TO 34
EQU SQL.MAX.TABLE.NAME.LEN TO 35
EQU SQL.MULT.RESULT.SETS TO 36
EQU SQL.MULTIPLE.ACTIVE.TXN TO 37
EQU SQL.OUTER.JOINS TO 38
EQU SQL.OWNER.TERM TO 39
EQU SQL.PROCEDURE.TERM TO 40
EQU SQL.QUALIFIER.NAME.SEPARATOR TO 41
EQU SQL.QUALIFIER.TERM TO 42
EQU SQL.SCROLL.CONCURRENCY TO 43
E-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppE
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.SCROLL.OPTIONS TO 44
EQU SQL.TABLE.TERM TO 45
EQU SQL.TXN.CAPABLE TO 46
EQU SQL.USER.NAME TO 47
EQU SQL.CONVERT.FUNCTIONS TO 48
EQU SQL.NUMERIC.FUNCTIONS TO 49
EQU SQL.STRING.FUNCTIONS TO 50
EQU SQL.SYSTEM.FUNCTIONS TO 51
EQU SQL.TIMEDATE.FUNCTIONS TO 52
EQU SQL.CONVERT.BIGINT TO 53
EQU SQL.CONVERT.BINARY TO 54
EQU SQL.CONVERT.BIT TO 55
EQU SQL.CONVERT.CHAR TO 56
EQU SQL.CONVERT.DATE TO 57
EQU SQL.CONVERT.DECIMAL TO 58
EQU SQL.CONVERT.DOUBLE TO 59
EQU SQL.CONVERT.FLOAT TO 60
EQU SQL.CONVERT.INTEGER TO 61
EQU SQL.CONVERT.LONGVARCHAR TO 62
EQU SQL.CONVERT.NUMERIC TO 63
EQU SQL.CONVERT.REAL TO 64
EQU SQL.CONVERT.SMALLINT TO 65
EQU SQL.CONVERT.TIME TO 66
EQU SQL.CONVERT.TIMESTAMP TO 67
EQU SQL.CONVERT.TINYINT TO 68
EQU SQL.CONVERT.VARBINARY TO 69
EQU SQL.CONVERT.VARCHAR TO 70
EQU SQL.CONVERT.LONGVARBINARY TO 71
EQU SQL.TXN.ISOLATION.OPTION TO 72
EQU SQL.ODBC.SQL.OPT.IEF TO 73
EQU SQL.CORRELATION.NAME TO 74
EQU SQL.NON.NULLABLE.COLUMNS TO 75
EQU SQL.DRIVER.HLIB TO 76
EQU SQL.DRIVER.ODBC.VER TO 77
EQU SQL.LOCK.TYPES TO 78
EQU SQL.POS.OPERATIONS TO 79
EQU SQL.POSITIONED.STATEMENTS TO 80
EQU SQL.GETDATA.EXTENSIONS TO 81
EQU SQL.BOOKMARK.PERSISTENCE TO 82
EQU SQL.STATIC.SENSITIVITY TO 83
EQU SQL.FILE.USAGE TO 84
EQU SQL.NULL.COLLATION TO 85
EQU SQL.ALTER.TABLE TO 86
EQU SQL.COLUMN.ALIAS TO 87
EQU SQL.GROUP.BY TO 88
EQU SQL.KEYWORDS TO 89
EQU SQL.ORDER.BY.COLUMNS.IN.SELECT TO 90
EQU SQL.OWNER.USAGE TO 91
EQU SQL.QUALIFIER.USAGE TO 92
EQU SQL.QUOTED.IDENTIFIER.CASE TO 93
EQU SQL.SPECIAL.CHARACTERS TO 94
EQU SQL.SUBQUERIES TO 95
EQU SQL.UNION TO 96
EQU SQL.MAX.COLUMNS.IN.GROUP.BY TO 97
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.MAX.COLUMNS.IN.INDEX TO 98
EQU SQL.MAX.COLUMNS.IN.ORDER.BY TO 99
EQU SQL.MAX.COLUMNS.IN.SELECT TO 100
EQU SQL.MAX.COLUMNS.IN.TABLE TO 101
EQU SQL.MAX.INDEX.SIZE TO 102
EQU SQL.MAX.ROW.SIZE.INCLUDES.LONG TO 103
EQU SQL.MAX.ROW.SIZE TO 104
EQU SQL.MAX.STATEMENT.LEN TO 105
EQU SQL.MAX.TABLES.IN.SELECT TO 106
EQU SQL.MAX.USER.NAME.LEN TO 107
EQU SQL.MAX.CHAR.LITERAL.LEN TO 108
EQU SQL.TIMEDATE.ADD.INTERVALS TO 109
EQU SQL.TIMEDATE.DIFF.INTERVALS TO 110
EQU SQL.NEED.LONG.DATA.LEN TO 111
EQU SQL.MAX.BINARY.LITERAL.LEN TO 112
EQU SQL.LIKE.ESCAPE.CLAUSE TO 113
EQU SQL.QUALIFIER.LOCATION TO 114
* SQL_ALTER_TABLE bitmasks *
EQU SQL.AT.ADD.COLUMN TO 1
EQU SQL.AT.DROP.COLUMN TO 2
* SQL_BOOKMARK_PERSISTENCE bitmasks *
EQU SQL.BP.CLOSE TO 1
EQU SQL.BP.DELETE TO 2
EQU SQL.BP.DROP TO 4
EQU SQL.BP.TRANSACTION TO 8
EQU SQL.BP.UPDATE TO 16
EQU SQL.BP.OTHER.HSTMT TO 32
EQU SQL.BP.SCROLL TO 64
* SQL_CONCAT_NULL_BEHAVIOR values *
EQU SQL.CB.NULL TO 0
EQU SQL.CB.NON.NULL TO 1
* SQL_CURSOR_COMMIT_BEHAVIOR values *
* SQL_CURSOR_ROLLBACK_BEHAVIOR values *
EQU SQL.CB.DELETE TO 0
EQU SQL.CB.CLOSE TO 1
EQU SQL.CB.PRESERVE TO 2
* SQL_CORRELATION_NAME values *
EQU SQL.CN.NONE TO 0
EQU SQL.CN.DIFFERENT TO 1
EQU SQL.CN.ANY TO 2
* SQL_CONVERT_<.> bitmasks *
EQU SQL.CVT.CHAR TO 1
EQU SQL.CVT.NUMERIC TO 2
EQU SQL.CVT.DECIMAL TO 4
EQU SQL.CVT.INTEGER TO 8
EQU SQL.CVT.SMALLINT TO 16
EQU SQL.CVT.FLOAT TO 32
EQU SQL.CVT.REAL TO 64
E-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppE
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
* SQL_FETCH_DIRECTION bitmask *
EQU SQL.FD.FETCH.NEXT TO 1
EQU SQL.FD.FETCH.FIRST TO 2
EQU SQL.FD.FETCH.LAST TO 4
EQU SQL.FD.FETCH.PRIOR TO 8
EQU SQL.FD.FETCH.ABSOLUTE TO 16
EQU SQL.FD.FETCH.RELATIVE TO 32
EQU SQL.FD.FETCH.RESUME TO 64
EQU SQL.FD.FETCH.BOOKMARK TO 128
* SQL_FILE_USAGE values *
EQU SQL.FILE.NOT.SUPPORTED TO 0
EQU SQL.FILE.TABLE TO 1
EQU SQL.FILE.QUALIFIER TO 2
* SQL_CONVERT_FUNCTIONS bitmask *
EQU SQL.FN.CVT.CONVERT TO 1
* SQL_NUMERIC_FUNCTIONS bitmask *
EQU SQL.FN.NUM.ABS TO 1
EQU SQL.FN.NUM.ACOS TO 2
EQU SQL.FN.NUM.ASIN TO 4
EQU SQL.FN.NUM.ATAN TO 8
EQU SQL.FN.NUM.ATAN2 TO 16
EQU SQL.FN.NUM.CEILING TO 32
EQU SQL.FN.NUM.COS TO 64
EQU SQL.FN.NUM.COT TO 128
EQU SQL.FN.NUM.EXP TO 256
EQU SQL.FN.NUM.FLOOR TO 512
EQU SQL.FN.NUM.LOG TO 1024
EQU SQL.FN.NUM.MOD TO 2048
EQU SQL.FN.NUM.SIGN TO 4096
EQU SQL.FN.NUM.SIN TO 8192
EQU SQL.FN.NUM.SQRT TO 16384
EQU SQL.FN.NUM.TAN TO 32768
EQU SQL.FN.NUM.PI TO 65536
EQU SQL.FN.NUM.RAND TO 131072
EQU SQL.FN.NUM.DEGREES TO 262144
EQU SQL.FN.NUM.LOG10 TO 524288
EQU SQL.FN.NUM.POWER TO 1048576
EQU SQL.FN.NUM.RADIANS TO 2097152
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
* SQL_STRING_FUNCTIONS bitmask *
EQU SQL.FN.STR.CONCAT TO 1
EQU SQL.FN.STR.INSERT TO 2
EQU SQL.FN.STR.LEFT TO 4
EQU SQL.FN.STR.LTRIM TO 8
EQU SQL.FN.STR.LENGTH TO 16
EQU SQL.FN.STR.LOCATE TO 32
EQU SQL.FN.STR.LCASE TO 64
EQU SQL.FN.STR.REPEAT TO 128
EQU SQL.FN.STR.REPLACE TO 256
EQU SQL.FN.STR.RIGHT TO 512
EQU SQL.FN.STR.RTRIM TO 1024
EQU SQL.FN.STR.SUBSTRING TO 2048
EQU SQL.FN.STR.UCASE TO 4096
EQU SQL.FN.STR.ASCII TO 8192
EQU SQL.FN.STR.CHAR TO 16384
EQU SQL.FN.STR.DIFFERENCE TO 32768
EQU SQL.FN.STR.LOCATE.2 TO 65536
EQU SQL.FN.STR.SOUNDEX TO 131072
EQU SQL.FN.STR.SPACE TO 262144
* SQL_SYSTEM_FUNCTIONS bitmask *
EQU SQL.FN.SYS.USERNAME TO 1
EQU SQL.FN.SYS.DBNAME TO 2
EQU SQL.FN.SYS.IFNULL TO 4
* SQL_TIMEDATE bitmask *
EQU SQL.FN.TD.NOW TO 1
EQU SQL.FN.TD.CURDATE TO 2
EQU SQL.FN.TD.DAYOFMONTH TO 4
EQU SQL.FN.TD.DAYOFWEEK TO 8
EQU SQL.FN.TD.DAYOFYEAR TO 16
EQU SQL.FN.TD.MONTH TO 32
EQU SQL.FN.TD.QUARTER TO 64
EQU SQL.FN.TD.WEEK TO 128
EQU SQL.FN.TD.YEAR TO 256
EQU SQL.FN.TD.CURTIME TO 512
EQU SQL.FN.TD.HOUR TO 1024
EQU SQL.FN.TD.MINUTE TO 2048
EQU SQL.FN.TD.SECOND TO 4096
EQU SQL.FN.TD.TIMESTAMPADD TO 8192
EQU SQL.FN.TD.TIMESTAMPDIFF TO 16384
EQU SQL.FN.TD.DAYNAME TO 32768
EQU SQL.FN.TD.MONTHNAME TO 65536
* SQL_TIMEDATE_ADD_INTERVALS bitmask *
* SQL_TIMEDATE_DIFF_INTERVALS bitmask *
EQU SQL.FN.TSI.FRAC.SECOND TO 1
EQU SQL.FN.TSI.SECOND TO 2
EQU SQL.FN.TSI.MINUTE TO 4
EQU SQL.FN.TSI.HOUR TO 8
E-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppE
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.FN.TSI.DAY TO 16
EQU SQL.FN.TSI.WEEK TO 32
EQU SQL.FN.TSI.MONTH TO 64
EQU SQL.FN.TSI.QUARTER TO 128
EQU SQL.FN.TSI.YEAR TO 256
* SQL_GROUP_BY values *
EQU SQL.GB.NOT.SUPPORTED TO 0
EQU SQL.GB.GROUP.BY.EQUALS.SELECT TO 1
EQU SQL.GB.GROUP.BY.CONTAINS.SELECT TO 2
EQU SQL.GB.NO.RELATION TO 3
* SQL_GETDATA_EXTENSIONS values *
EQU SQL.GD.ANY.COLUMN TO 1
EQU SQL.GD.ANY.ORDER TO 2
EQU SQL.GD.BLOCK TO 4
EQU SQL.GD.BOUND TO 8
* SQL_IDENTIFIER_CASE values *
* SQL_QUOTED_IDENTIFIER values *
EQU SQL.IC.UPPER TO 1
EQU SQL.IC.LOWER TO 2
EQU SQL.IC.SENSITIVE TO 3
EQU SQL.IC.MIXED TO 4
* SQL_LOCK_TYPES bitmask *
EQU SQL.LCK.NO.CHANGE TO 1
EQU SQL.LCK.EXCLUSIVE TO 2
EQU SQL.LCK.UNLOCK TO 4
* SQL_NULL_COLLATION values *
EQU SQL.NC.HIGH TO 0
EQU SQL.NC.LOW TO 1
EQU SQL.NC.START TO 2
EQU SQL.NC.END TO 4
* SQL_NON_NULLABLE_COLUMNS values *
EQU SQL.NNC.NULL TO 0
EQU SQL.NNC.NON.NULL TO 1
* SQL_ODBC_API_CONFORMANCE *
EQU SQL.OAC.NONE TO 0
EQU SQL.OAC.LEVEL1 TO 1
EQU SQL.OAC.LEVEL2 TO 2
* SQL_ODBC_SQL_CONFORMANCE values *
EQU SQL.OSC.MINIMUM TO 0
EQU SQL.OSC.CORE TO 1
EQU SQL.OSC.EXTENDED TO 2
* SQL_ODBC_SAG_CLI_CONFORMANCE values *
EQU SQL.OSCC.NOT.COMPLIANT TO 0
EQU SQL.OSCC.COMPLIANT TO 1
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
* SQL_OWNER_USAGE bitmask *
EQU SQL.OU.DML.STATEMENTS TO 1
EQU SQL.OU.PROCEDURE.INVOCATION TO 2
EQU SQL.OU.TABLE.DEFINITION TO 4
EQU SQL.OU.INDEX.DEFINITION TO 8
EQU SQL.OU.PRIVILEGE.DEFINITION TO 16
* SQL_POS_OPERATIONS *
EQU SQL.POS.POSITION TO 1
EQU SQL.POS.REFRESH TO 2
EQU SQL.POS.UPDATE TO 4
EQU SQL.POS.DELETE TO 8
EQU SQL.POS.ADD TO 16
* SQL_POSITIONED_STATEMENTS bitmask *
EQU SQL.PS.POSITIONED.DELETE TO 1
EQU SQL.PS.POSITIONED.UPDATE TO 2
EQU SQL.PS.SELECT.FOR.UPDATE TO 4
* SQL_DEFAULT_TXN_ISOLATION bitmask *
* SQL_TXN_ISOLATION_OPTION bitmask *
EQU SQL.TXN.READ.UNCOMMITTED TO 1
EQU SQL.TXN.READ.COMMITTED TO 2
EQU SQL.TXN.REPEATABLE.READ TO 4
EQU SQL.TXN.SERIALIZABLE TO 8
EQU SQL.TXN.VERSIONING TO 16
EQU SQL.TXN.CURRENT TO 42
* SQL_QUALIFIER_LOCATION values *
EQU SQL.QL.START TO 1
EQU SQL.QL.END TO 2
* SQL_QUALIFIER_USAGE bitmask *
EQU SQL.QU.DML.STATEMENTS TO 1
EQU SQL.QU.PROCEDURE.INVOCATION TO 2
EQU SQL.QU.TABLE.DEFINITION TO 4
EQU SQL.QU.INDEX.DEFINITION TO 8
EQU SQL.QU.PRIVILEGE.DEFINITION TO 16
* SQL_SCROLL_CONCURRENCY bitmask *
EQU SQL.SCCO.READ.ONLY TO 1
EQU SQL.SCCO.LOCK TO 2
EQU SQL.SCCO.OPT.ROWVER TO 4
EQU SQL.SCCO.OPT.VALUES TO 8
* SQL_SCROLL_OPTIONS bitmask *
EQU SQL.SO.FORWARD.ONLY TO 1
EQU SQL.SO.KEYSET.DRIVEN TO 2
EQU SQL.SO.DYNAMIC TO 4
EQU SQL.SO.MIXED TO 8
EQU SQL.SO.STATIC TO 16
* SQL_STATIC_SENSITIVITY bitmask *
EQU SQL.SS.ADDITIONS TO 1
E-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\AppE
3/12/10
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
EQU SQL.SS.DELETIONS TO 2
EQU SQL.SS.UPDATES TO 4
* SQL_SUBQUERIES bitmask *
EQU SQL.SQ.COMPARISON TO 1
EQU SQL.SQ.EXISTS TO 2
EQU SQL.SQ.IN TO 4
EQU SQL.SQ.QUANTIFIED TO 8
EQU SQL.SQ.CORRELATED.SUBQUERIES TO 16
* SQL_TXN_CAPABLE values *
EQU SQL.TC.NONE TO 0
EQU SQL.TC.DML TO 1
EQU SQL.TC.ALL TO 2
EQU SQL.TC.DDL.COMMIT TO 3
EQU SQL.TC.DDL.IGNORE TO 4
* SQL_UNION values *
EQU SQL.U.UNION TO 1
EQU SQL.U.UNION.ALL TO 2
EQU SQL.BEST.ROWID TO 1
EQU SQL.ROWVER TO 2
EQU SQL.SCOPE.CURROW TO 0
EQU SQL.SCOPE.TRANSACTION TO 1
EQU SQL.SCOPE.SESSION TO 2
EQU SQL.PC.UNKNOWN TO 0
EQU SQL.PC.PSEUDO TO 1
EQU SQL.PC.NOT.PSEUDO TO 2
Glossary
application A user program that issues function calls to submit SQL statements and
program retrieve results, and then processes those results.
association A group of related multivalued columns in a table. The first value in any
association column corresponds to the first value of every other column
in the association, the second value corresponds to the second value,
and so on. An association can be thought of as a nested table. A
multivalued column that is not associated with other columns is treated
as an association comprising one column.
connection Memory allocated and initialized with data necessary to describe and
environment maintain a connection between the SQL Client Interface and the data
source. Several connection environments can connect to a single
ODBC environment.
cursor A virtual pointer to the set of results produced by a query. The SQL
Client Interface cursor points to one row of data at a time. An
application can advance the cursor only one row at a time.
DDL Data definition language. A subset of SQL statements used for creating,
altering, and dropping schemas, tables, and views.
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta
DLL Dynamic link library. A collection of functions linked together into a unit that can be
distributed to application developers. When the program runs, the application
attaches itself to the DLL when the program calls one of the DLL functions.
DML Data manipulation language. A subset of SQL statements used for retrieving,
inserting, modifying, and deleting data. These statements include SELECT, INSERT,
UPDATE, and DELETE.
data source The data you want to access, the DBMS it is associated with, and the server the
DBMS resides on. For example, a data source ORA could refer to an ORACLE
DBMS on node SERVER1, with ORACLE SID ALPHA. ODBC data sources do not
contain user ID and password information.
driver A program that processes function calls, submits SQL requests to a specific data
source, and returns results to the client application program.
driver manager A program that loads and initializes drivers on behalf of a client application program.
embedded SQL An interface mechanism that includes SQL statements in source code. The SQL
statements are precompiled, converting the embedded SQL statements into the
language of the host program.
environment A pointer to a data area that contains global information concerning the state of the
handle application, including the valid connection handles and the current active connection
handle.
isolation level A mechanism for separating a transaction from other transactions running
concurrently, so that no transaction affects any of the others. There are five isolation
levels, numbered 0 through 4.
middleware Software that acts as a bridge between two different database systems. The UniRPC
is middleware for UniVerse and UniData servers. Other servers use various ODBC
drivers as middleware.
multivalued A column that can contain more than one value for each row in a table.
column
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta
null value A special value representing an unknown value. Not the same as 0 (zero), a blank, or
an empty string.
ODBC Open Database Connectivity. The Microsoft version of the SQL Access Group Call
Level Interface (SAG CLI). Microsoft adds extensions to the SAG CLI that target it
at the Windows marketplace.
ODBC driver Software that acts as a bridge between a client system and a specific database system.
ODBC driver Software that fields all entry points defined by the ODBC specification. It performs
manager any common functions required by all databases, then passes function calls to
specific ODBC drivers.
precision The maximum number of digits defined for SQL data types.
prepared SQL An SQL statement that has been checked before being passed to the server for
statement execution.
programmatic A subset of the SQL language. Programmatic SQL differs from interactive SQL in
SQL that certain keywords and clauses used for report formatting in interactive mode are
not supported in programmatic SQL.
result set A set of rows of data obtained via the SQLFetch call. A result set is returned when
an SQL SELECT statement is executed. It is also returned by the SQLColumns and
SQLTables calls.
SAG CLI SQL access group call level interface. See ODBC.
scale The maximum number of digits to the right of the decimal point.
single-valued A column that can contain only one value for each row in a table.
column
SQL Client Memory allocated and initialized with data necessary to describe all connections to
Interface data sources and all SQL statements being executed at those data sources. All
environment connection environments and SQL statement environments are attached to an SQL
Client Interface environment.
Glossary 3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\10.3rebranded\bci\Glossary
3/12/10
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta
SQL statement Memory allocated and initialized to let the software describe all context of an SQL
environment statement executed at a data source. An SQL statement environment is attached to a
connection environment.
UniRPC Remote procedure call. A UniVerse middleware facility that receives requests from
remote machines for services and that starts those services.
unirpcservices The UniRPC services file, located on the server, which verifies client requests for
services.
uvodbc.config The client ODBC configuration file, which defines SQL client connections to a
server in terms of DBMS, network, service, and host.
uvserver The UniVerse server process to which the client application connects.