IBM Universe UCI
IBM Universe UCI
IBM Universe UCI
2A\uci\Front
February 21, 2008 3:40 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta
UniVerse
Version 10.2
February, 2008
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Front
February 21, 2008 3:40 pm
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
IBM Corporation
555 Bailey Avenue
San Jose, CA 95141
© Copyright International Business Machines Corporation 2006, 2008. All rights reserved.
AIX, DB2, DB2 Universal Database, Distributed Relational Database Architecture, NUMA-Q, OS/2, OS/390, and
OS/400, IBM Informix®, C-ISAM®, Foundation.2000 ™, IBM Informix® 4GL, IBM Informix® DataBlade® module,
Client SDK™, Cloudscape™, Cloudsync™, IBM Informix® Connect, IBM Informix® Driver for JDBC, Dynamic
Connect™, IBM Informix® Dynamic Scalable Architecture™ (DSA), IBM Informix® Dynamic Server™, IBM
Informix® Enterprise Gateway Manager (Enterprise Gateway Manager), IBM Informix® Extended Parallel Server™,
i.Financial Services™, J/Foundation™, MaxConnect™, Object Translator™, Red Brick® Decision Server™, IBM
Informix® SE, IBM Informix® SQL, InformiXML™, RedBack®, SystemBuilder™, U2™, UniData®, UniVerse®,
wIntegrate® are trademarks or registered trademarks of International Business Machines Corporation.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the
United States and other countries.
Windows, Windows NT, and Excel are either registered trademarks or trademarks of Microsoft Corporation in the United
States and/or other countries.
UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company
Limited.
Other company, product, and service names used in this publication may be trademarks or service marks of others.
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Table of Contents
Preface
Organization of This Manual . . . . . . . . . . . . . . . viii
Documentation Conventions. . . . . . . . . . . . . . . . ix
Hungarian Naming Conventions . . . . . . . . . . . . . xi
Help . . . . . . . . . . . . . . . . . . . . . . . xii
UniVerse Documentation. . . . . . . . . . . . . . . . . xiii
Related Documentation . . . . . . . . . . . . . . . . . xvi
API Documentation . . . . . . . . . . . . . . . . . . xvii
Chapter 1 Introduction
What Is an SQL Call Interface?. . . . . . . . . . . . . . . 1-3
SQL Call Interface Versus Embedded SQL . . . . . . . . . 1-3
Advantages of Call Interfaces. . . . . . . . . . . . . . 1-4
Language Support . . . . . . . . . . . . . . . . . . . 1-5
Operating Platforms . . . . . . . . . . . . . . . . . . 1-6
Compliance with the ODBC 2.0 Standard . . . . . . . . . . . 1-7
Requirements for UCI Applications . . . . . . . . . . . . . 1-8
Table of Contents v
SQLDisconnect . . . . . . . . . . . . . . . . .
8-56
SQLError . . . . . . . . . . . . . . . . . . .
8-58
SQLExecDirect . . . . . . . . . . . . . . . . .
8-62
SQLExecute . . . . . . . . . . . . . . . . . .
8-66
SQLFetch . . . . . . . . . . . . . . . . . . .
8-69
SQLFreeConnect . . . . . . . . . . . . . . . . .
8-73
SQLFreeEnv . . . . . . . . . . . . . . . . . .
8-75
SQLFreeMem . . . . . . . . . . . . . . . . . .
8-77
SQLFreeStmt . . . . . . . . . . . . . . . . . .
8-78
SQLGetData . . . . . . . . . . . . . . . . . .
8-81
SQLGetFunctions . . . . . . . . . . . . . . . . .
8-85
SQLGetInfo . . . . . . . . . . . . . . . . . .
8-89
SQLNumParams . . . . . . . . . . . . . . . . . . . 8-98
SQLNumResultCols . . . . . . . . . . . . . . . . 8-100
SQLParamOptions . . . . . . . . . . . . . . . . 8-102
SQLPrepare . . . . . . . . . . . . . . . . . . 8-105
SQLRowCount . . . . . . . . . . . . . . . . . 8-109
SQLSetConnectOption . . . . . . . . . . . . . . . 8-111
SQLSetParam . . . . . . . . . . . . . . . . . . 8-117
SQLTables . . . . . . . . . . . . . . . . . . . 8-120
SQLTransact . . . . . . . . . . . . . . . . . . 8-125
SQLUseCfgFile . . . . . . . . . . . . . . . . . . . 8-129
Preface
This manual describes how to use UCI (Uni Call Interface). UCI is a C-language
application programming interface that lets application developers create client
programs that use SQL functions to access data in UniVerse and UniData databases.
You should have a working knowledge of UniVerse or UniData, C, and SQL, and
have an understanding of client/server protocols.
vii
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Preface
2/21/08
Chapter 1, “Introduction,” describes UCI, its relationship to the ODBC 2.0 standard,
and what you need to run it.
Chapter 2, “Getting Started,” tells how to install UCI, how to run the sample appli-
cation program, and how to compile, link, install, and execute a client application
program that uses UCI.
Chapter 3, “Configuring UCI,” tells how to modify the configuration file (uci.config)
that fine-tunes the UCI process.
Chapter 5, “Calling and Executing UniVerse Procedures,” describes how to call and
execute procedures stored on a UniVerse data source.
Chapter 8, “UCI Functions,” is the technical reference for UCI function calls.
Appendix A, “Error Codes,” lists the SQLSTATE return codes and their meaning.
Documentation Conventions
This manual uses the following conventions:
Convention Usage
Courier Bold In examples, courier bold indicates characters 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.
ix
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Preface
2/21/08
Convention Usage
V Value mark. For example, the value mark ( V ) in the following
string delimits elements VAL1 and SUBV1:
FLD1FVAL1VSUBV1SSUBV2
S Subvalue mark. For example, the subvalue mark ( S ) in the
following string delimits elements SUBV1 and SUBV2:
FLD1FVAL1VSUBV1SSUBV2
T Text mark. For example, the text mark ( T ) in the following string
delimits elements 4 and 5: 1F2S3V4T5
Documentation Conventions (Continued)
The following conventions are also used:
x Administering UniVerse
C:\Program
Files\Adobe\FrameMaker8\UniVerse
Help
To get Help about UCI, choose Programs -> IBM U2 -> UniDK -> UCI – Help from
the Start menu.
xi
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Preface
2/21/08
UniVerse Documentation
UniVerse documentation includes the following:
UniVerse New Features Version 10.2: Describes enhancements and changes made
in the UniVerse 10.2 release for all UniVerse products.
UniVerse BASIC SQL Client Interface Guide: Describes how to use the 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, IBM, SYBASE, or INFORMIX. This book is for experienced SQL
programmers.
Using UniAdmin: Describes the UniAdmin tool, which enables you to configure
UniVerse, configure and manager servers and databases, and monitor UniVerse
performance and locks.
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).
xiii
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Preface
2/21/08
Related Documentation
The following documentation is also available:
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 use UniVerse ODBC
Config and 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.
UniVerse Guide for Pick Users: Describes UniVerse for new UniVerse users familiar
with Pick-based systems.
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, 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
UniData and UniVerse databases from JDBC applications. This book is for experi-
enced 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 experi-
enced 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.
xv
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Preface
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Introduction
1
What Is an SQL Call Interface? . . . . . . . . . . . . . . 1-3
SQL Call Interface Versus Embedded SQL . . . . . . . . . 1-3
Advantages of Call Interfaces . . . . . . . . . . . . . 1-4
Language Support . . . . . . . . . . . . . . . . . . 1-5
Operating Platforms . . . . . . . . . . . . . . . . . . 1-6
Compliance with the ODBC 2.0 Standard . . . . . . . . . . . 1-7
Requirements for UCI Applications . . . . . . . . . . . . . 1-8
UCI is designed for use by third-party application developers, tools vendors, and end-
user developers who want to write C-hosted, SQL-based client programs for use with
tables and files in a database account.
Dynamic SQL functionality lets a client application both generate and execute SQL
statements at run time. Generally, each SQL statement is prepared before execution,
with the database server generating a data access plan and a description of the result
set; the statement can then be executed repeatedly using the same access path,
reducing processing overhead. Another significant feature of dynamic SQL is the
ability to include parameters in SQL statements. Parameters are like host variables in
embedded SQL, with values assigned to the parameters before execution or retrieved
from them after execution.
1-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch1
2/21/08
Language Support
UCI is targeted to application development in C, but the library is linkable with and
works with client programs written in other languages, including C++.
UCI fully supports the UniVerse programmatic SQL language, as defined in UCI
Developer’s Guide.
Operating Platforms
The database server can be either on the same platform as the application or on a
different platform accessible through either a TCP/IP or a LAN Manager network
(network software must be installed even for local access). Neither UniVerse nor
UniData needs to be installed on the client platform.
The network connection uses the UniRPC, a remote procedure call library.
1-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch1
2/21/08
On a UNIX server:
UniVerse Release 8.3.3 or later; or UniData Release 5.1 or later
TCP/IP
UniRPC daemon (unirpcd) running
On a Windows server:
UniVerse Release 9.3.1 or later; or UniData Release 5.1 or later
TCP/IP, if connected to a UNIX client
TCP/IP or LAN Manager, if connected to a Windows client
UniRPC service (unirpc) running
On a UNIX client:
TCP/IP
Required UCI files copied from the software development kit (SDK)
On a Windows client:
TCP/IP, if connected to a UNIX server
TCP/IP or LAN Manager, if connected to a Windows server
Required UCI files copied from the software development kit (SDK)
1-7
1Administering 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 Beta Beta
Chapter
Getting Started
2
Installing UCI. . . . . . . . . . . . . . . . . . . . 2-3
On UNIX Systems . . . . . . . . . . . . . . . . . 2-3
On Windows Systems . . . . . . . . . . . . . . . . 2-4
Version Compatibility . . . . . . . . . . . . . . . . 2-4
Creating and Running the Sample Application . . . . . . . . . 2-6
Creating and Running Client Programs . . . . . . . . . . . . 2-8
UCI Administration . . . . . . . . . . . . . . . . . . 2-10
Maintaining the UCI Configuration File . . . . . . . . . . 2-10
Administering the UniRPC . . . . . . . . . . . . . . 2-10
Install UCI
Create and run the sample application
Create and run client application programs developed using UCI
Perform the necessary system administration
Installing UCI
The installation of UCI is different on UNIX and Windows platforms.
On UNIX Systems
The UCI software development kit (SDK) is included on the UniVerse installation
media for UNIX systems. It is installed from the UCI group as part of the standard
UniVerse installation.
The installation process creates a directory called ucisdk in the unishared directory,
whose path is stored in the file /.unishared. The ucisdk directory contains the
following files:
File Description
ucisample.c C source code for a sample UCI program ucisample. Program code for
ucisample.c is in Appendix B, “The UCI Sample Program.”
Make.UCI A make file for building ucisample. Make.UCI varies from platform to
platform. The Make.UCI supplied is customized for your platform.
2-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch2
2/21/08
On Windows Systems
UCI is available for 32-bit Windows only. It is one of several APIs in the UniDK (Uni
Development Kit). The UniDK is installed using the standard Microsoft Windows
installation procedure. The following UniDK files are used for UCI development:
File Description
Version Compatibility
New versions of the UCI server components in the unishared directory are backward-
compatible with earlier versions, so you can always upgrade the unishared directory.
However, if you upgrade unishared in a new location, you can revert to the older
unishared directory by doing the following:
2. If you have done any of the following since you last used the older
unishared directory:
Uninstalled the database without reinstalling in the same directory.
Upgraded the database in a different directory
Installed a new instance of the database
Copy the following files from the newer unishared directory to the older
one:
unishared\sharedby
unishared\unirpc\unirpcservices
Make sure these files have the same permissions and ownership as before.
3. On UNIX systems: Update the file /.unishared to contain the absolute
pathname of the older unishared directory.
On Windows platforms: Do the following:
Update the Registry Value
HKEY_LOCAL_MACHINE\SOFTWARE\ibm\unishared\path to contain the
absolute path of the older unishared directory.
Update the Registry Value
HKEY_LOCAL_MACHINE\SYSTEM\CurrentCon-
trolSet\Services\unirpc\ImagePath to contain the following path:
unishared\unirpc\unirpcd.exe
unishared is the full path of the older unishared directory.
Copy the file unishared\unirpc\unirpc32.dll.bak from the old directory
to the Windows\system32 directory, then rename it unirpc32.dll.
Restart your PC.
4. Restart the database.
2-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch2
2/21/08
6. At the prompt, enter the location of the demo data files on the server. You
can specify the location as one of the following:
The name of a schema
The name of a database account
The full path of a schema directory
7. At the prompt, enter a user name that is valid on the server.
8. At the prompt, enter the user’s password. The password is not echoed to the
screen.
The sample program uses UCI to issue SQL statements against the files
created in step 2. As the program executes, it informs you of its progress.
2-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch2
2/21/08
To create and run your own client application programs, complete the following
steps:
4. Before running the application, edit the UCI configuration file to define the
data source to which the application will connect. Use the UCI Config
Editor to create data source definitions in the UCI configuration file (for
details see Administrative Supplement for Client APIs).
The supplied UCI configuration file includes two data source definitions,
localuv and localud, for the local database. If your application needs to
connect to some other database, you must edit the UCI configuration file.
Chapter 3, “Configuring UCI,” provides more information about this
configuration file.
2-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch2
2/21/08
UCI Administration
Once UCI has been installed, it needs little administration. The only major tasks are:
The client searches for the UCI configuration file (and the ucimsg.text file) in the
following places:
In particular, the UniRPC daemon (unirpcd) on UNIX systems, and the unirpc
service on Windows platforms, receive SQLConnect requests and start the appro-
priate server processes to support each UCI application. On UNIX each UCI
application has two supporting processes (uvserver and uvsrvhelpd) on the server
while the application is connected. On Windows platforms, a helper thread runs as
part of the uvserver process. The uvserver process uses the same amount of system
resources as a local database user.
Before any UCI client applications can run, the administrator of the database server
must ensure that the UniRPC daemon or service is running on the server. The UNIX
server machine must be running Release 8.3.3 or later of UniVerse. The Windows
server machine must be running Release 9.3.1 or later.
See Administrative Supplement for Client APIs for more information about the
UniRPC, including how to do the following:
Administrative Supplement for Client APIs also describes the structure and function
of the unirpcservices file in the unirpc directory. The unirpcservices file contains
entries for uvserver and udserver.
2-11
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 Beta Beta
Chapter
Configuring UCI
3
Configuring a Database Server for UCI. . . . . . . . . . . . 3-3
UniRPC . . . . . . . . . . . . . . . . . . . . 3-3
UniVerse NLS . . . . . . . . . . . . . . . . . . 3-4
Configuring a Client System for UCI . . . . . . . . . . . . 3-5
Configuration Parameters. . . . . . . . . . . . . . . 3-5
Editing the UCI Configuration File. . . . . . . . . . . . 3-8
Changing UCI Configuration File Parameters . . . . . . . . 3-10
Configuring UCI for an NLS-Enabled UniVerse Server . . . . . 3-12
This chapter describes how to configure both the client and the server systems for
UCI.
3-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
UniRPC
The UniVerse server (uvserver) uses the UniRPC facility (remote procedure call),
which is installed with UniVerse. To make UniVerse available as a server, the
UniRPC daemon (unirpcd) must be running on UNIX systems, or the unirpc service
must be running on Windows systems.
On UNIX systems, the UniRPC services file, unirpcservices, on the server must
contain an entry similar to the following:
When the client system requests a connection to a service on the server, the local
UniRPC daemon or service uses the unirpcservices file to verify that the client can
start the requested service, which in this case is uvserver. Once the daemon or service
is started, UCI clients can connect to the database server.
For more information about the UniRPC, see the Administrative Supplement for
Client APIs.
UniVerse NLS
If UniVerse is running with NLS enabled, you must install any character maps needed
by clients. If you need to modify existing maps or derive appropriate new maps to
install, use the UniVerse NLS menus, described in the UniVerse NLS Guide. The
easiest way to ensure that client programs use that map is to see that the client’s UCI
configuration file contains the name of the new map.
3-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
The following sections deal with those parameters of interest to UCI clients. Do not
change any of the other parameters in the UCI configuration file.
Configuration Parameters
Configuration parameters of interest to UCI developers are described in the following
table.
NETWORK Specifies the network used to access the data source none
(TCP/IP or LAN).
3-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
NLSMAP Specifies the name of the server’s NLS map for the none
connection. For a client to connect to the server
successfully, the server must be able to locate the
specified map, which must also be installed in the
server’s shared memory segment.
SERVICE Specifies the name of the server process for the none
DBMSTYPE you specified. For UniData, specify
udserver; for UniVerse, specify uvserver.
The following parameters are not used by UCI. They control the UniVerse BASIC
SQL Client Interface, which allows data interchange between a UniVerse client
BASIC program and a non-UniVerse or UniVerse database.
Warning: Do not define these parameters for any data source that points to a
UniVerse or UniData database. If you do, the results may be unpredictable.
3-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
On UNIX systems
The default UCI configuration file shipped with the database looks like this:
On Windows systems
The default UCI configuration file shipped with the database looks like this:
This default UCI configuration file lets you access a database on the same hardware
platform as the one on which your application is running.
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.
3-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
You can change these parameters for specific data sources or for all database
connections. Using the sample configuration file shown previously, you might add
entries for MAXFETCHBUFF and MAXFETCHCOLS as shown below to change
the internal default for those parameters to 16000 and 600, respectively:
To make the data source corp use larger buffers, make the following changes:
In this situation, you have set the default for connections to UniVerse to 16000 and
600, but when you connect to the data source corp, the local settings of 20000 and
800 override the defaults.
If clients need to override the default server map names and locale settings, you can
change the UCI configuration file to contain this information:
NLS users should note that the configuration file is in ASCII format. When you
specify NLS and locale settings in the configuration file, you need not make changes
to your programs to let client programs work with an NLS-enabled server.
Server Map
Use the NLSMAP parameter to specify the server map to use.
Server Locale
Use the following parameters to specify a locale’s components:
NLSLCTIME
NLSLCNUMERIC
NLSLCMONETARY
NLSLCCTYPE
NLSLCCOLLATE
NLSLCALL = value1/value2/value3/value4/value5
3-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch3
2/21/08
NLSLOCALE = DE-GERMAN
NLSLCALL = NL-DUTCH/NL-DUTCH/DEFAULT/NL-DUTCH/NL-
DUTCH
This sets all components of the locale for this connection to those indicated by the
entry in the NLS.LC table with ID = NL-DUTCH, except for the LCMONETARY
entry, which is loaded from the NLS.LC.MONETARY table for the DEFAULT entry.
If there is more than one entry in the NLSLCALL entry, all entries must be nonempty
and must represent valid entries in the appropriate NLS.LC.category table.
NLSLCCOLLATE = NO-NORWEGIAN
NLSLCCOLLATE is the most important locale parameter because it affects the order
in which rows are returned to the application.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
This chapter describes the steps to develop a UCI application program. It covers how
to code the three major sections of a program—initializing, processing, and
closing—and then discusses related topics such as how to handle the database’s
multivalued columns and how to check for and handle errors.
Phase Description
Processing Either passing SQL statements to UCI to retrieve and modify the data,
or calling and executing procedures stored on the data source.
In addition to these phases, a program must deal with error returns, which can occur
at any point in its execution. It can also request information about the database and
its accessible tables and columns.
Note: In this chapter and those following, certain elements of the Hungarian naming
convention are used when describing the elements of UCI calls (see Use of
Hungarian Naming Conventions in Chapter 8, “UCI Functions.”).
4-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
Initializing Resources
Before you can perform any actual processing, you must establish the necessary
connections. These are the four steps associated with this task:
These steps dynamically allocate objects to be used by the client interface (UCI) for
storing essential data between calls, create a handle (a pointer to a structure) for these
areas, and return that handle to the application program. Subsequently the application
program can return that handle to the client interface, when necessary, as a parameter
of a call. For each initialization step there is a corresponding step in the termination
process that frees these objects and handles.
The environment is of use only to UCI software. The client application program has
no need of it, and its only job is to store the returned handle and to release it at the end.
An application can have more than one connection, for connecting to more than one
schema or account or to more than one database server.
4-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
When a UCI program connects to an NLS-enabled UniVerse server, the map and
locale values the server uses depend on the settings of the parameters in the server’s
uvconfig and UCI configuration files, as well as values from the client’s operating
system and its UCI configuration file. All these values can be explicitly set by the
client.
The UniVerse server honors the following configurable parameters in its uvconfig
file:
Parameter Description
NLSDEFSRVMAP Specifies the default map to be used for passing string arguments to
and from client programs. Used if the client does not assign an
explicit map.
NLSDEFSRVLC Specifies the default locale for the server, which is used by all client
programs accessing the server.
Configuration Parameters
When the client application starts, it determines the default map and locale values to
send to the server as follows:
Client programs can use the SQLSetConnectOption call to override any of the
server’s default map and locale values.
UniVerse Release 9.4 (or Later) Client and Release 9.4 (or Later) Server
The following table shows which combinations of server map specification and
locale specification are allowed depending on the client type and the NLS status of
the server.
4-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
Are Any
NLS State Is Client Client
of the NLSMA Locale
Server P Set? Settings Set? Action
No No Connection succeeds.
NLS Map and Locale Settings
UniVerse Release 9.3 (or Earlier) Client and Release 9.4 (or Later) Server.
UniVerse releases before 9.4 do not support UniVerse NLS. Therefore, any Release
9.3 (or earlier) client cannot request a map or locale; it uses the server’s current map
and locale settings. If these are the NLS defaults, the results returned are the same as
those from a 9.3 or earlier server.
UniVerse Release 9.4 (or Later) Client and Release 9.3 (or Earlier) Server.
Because UniVerse releases before 9.4 do not support UniVerse NLS, Release 9.4
clients can connect to Release 9.3 (or earlier) servers only if the client does not
request NLS options.
4-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
Transaction Modes
Two transaction modes are supported: autocommit and manual-commit. By default,
the database is in autocommit mode, but you can put it into manual-commit mode by
calling SQLTransact with the SQL_BEGIN_TRANSACTION flag.
Autocommit Mode
In autocommit mode, each SQL statement is treated as a separate and complete trans-
action, and the server commits one transaction per statement. If no explicit
SQLTransact call is issued, all statements are processed in autocommit mode. Data
definition language (DDL) statements cannot be executed inside a transaction and
must be executed in autocommit mode. All SQLConnect and SQLDisconnect calls
must also be performed in autocommit mode.
Manual-Commit Mode
In manual-commit mode, a transaction begins with an SQLTransact call with an fType
of SQL_BEGIN_TRANSACTION. If another transaction is already active, this
transaction becomes a nested transaction.
The final step in manual-commit mode is to either commit or roll back the transaction
with another call to SQLTransact, this time with an fType of SQL_COMMIT or
SQL_ROLLBACK.
Function Calls
SQL statement processing can involve a number of function calls, as shown in the
following figure. This figure illustrates all the steps in SQL statement processing
except error checking. However, certain steps are optional. For example, instead of
releasing the statement handle after each SQL statement is processed and then
allocating a new handle for the next SQL statement, you could unbind the columns
and parameters associated with the handle and then reuse the handle for the next SQL
statement.
SQLExecDirect parses and binds an SQL statement to an hstmt and then executes it.
Whenever an application issues an SQLExecDirect call, UCI does the following:
4-11
Start transaction, set isolation level ---Optional (if not used,
each SQL statement is
SQLTransact
treated as a transaction
internally).
Allocate statement ---Optional (usually once a
statement environment has
SQLAllocStmt been allocated, it is reused) .
SQLBind[Mv]Col
SQLFetch
SQLGetData
SQLFreeMem
1. Passes the SQL statement to the server for query plan generation
2. Retrieves information about result set columns from the server if the
operation was a SELECT
3. Gets the current input parameter values, converts them, and sends them to
the data source (see “Using Parameter Markers in SQL Statements” on
page 14).
4. Requests that the server execute the statement with the parameters given
5. Gets output parameters from the data source and stores them in the
designated variables
6. Returns errors, if any
1. Greater efficiency for statements that are to be executed many times. The
data source produces an access plan for executing the SQL statement, and
then uses that same plan for each iteration of the statement.
2. The application can obtain information about the result set before actually
executing the statement.
When an application issues an SQLPrepare call, UCI does the following:
3. Passes the SQL statement for parsing
4. Retrieves information about the result set columns from the server if the
operation was a SELECT
1. Get the current parameter values, convert them, and send them to the data
source (see“Using Parameter Markers in SQL Statements” on page 14)
2. Request that the server execute the SQL statement
3. Get output parameters from the data source and store them in the designated
variables
4. Return errors, if any
4-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
Parameter markers are represented by a ? (question mark) and indicate places in the
SQL statement where application variables are to be substituted when the statement
is executed. Markers are numbered from left to right, starting with 1.
For example, if an application is inserting new rows of data into a simple four-column
SUPPLIER table, the INSERT statement might look like this:
In this example, there are four parameter markers, and the application must call
SQLBindParameter once for each marker.
Note: An SQLSetParam function is provided for compatibility with ODBC 1.0 and
the UniVerse BASIC SQL Client Interface. It binds an application buffer to a
parameter marker in an SQL statement, and is essentially a front end to the
SQLBindParameter call. Also, an SQLBindMvParameter function is included as a
database extension to handle parameter markers associated with multivalued
columns (see “Handling Multivalued Columns” on page 23 for more information). It
is usable with singlevalued columns as well.
A result set comprises one or more rows of data obtained by a SELECT statement or
called procedure. The application must retrieve the data one row at a time to process
it. When a result set is produced, UCI opens a cursor into that result set. A cursor is
a pointer to the next row of data that a fetch will return from the result set.
4-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
If the SELECT statement is not hard-coded but instead is generated at run time (for
example, entered ad hoc by a user), or is a SELECT *, the application needs to know
how many columns there are and their data types (as well as the names of the
columns).
Fetching Rows
SQLFetch reads each row of data, one row at a time, and places the content of each
column into the application variable to which it was bound by SQLBindCol (or
SQLBindMvCol). A cursor mechanism keeps track of the current position in the
rows. Each time an application calls SQLFetch, the cursor moves to the next row, the
row’s data is retrieved and converted, and the result for each bound column is placed
into its assigned storage variable. This process continues until there is no more data
to retrieve and SQL_NO_DATA_FOUND is returned. For unbound columns or
columns bound to variables that are too small, the application can issue an
SQLGetData call to get the remainder of the data.
Along with these return codes are SQLSTATEs, which are alphanumeric strings of
five characters that further define the warning or error condition indicated by the
return code. An application can interrogate the SQLSTATE by calling SQLError,
providing more detailed error information from the server.
Not all return codes provide additional SQLSTATE information, so first check the
return code to see if additional diagnostic information is available. Generally, when
an error occurs in an application, the error subroutine displays or prints the name of
the function, the return code, the content of SQLSTATE, the database error code, and
the diagnostic text.
Unbind all bound columns and parameters associated with the statement
Reset parameter markers associated with the statement
Drop the statement handle and release its associated resources
4-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
After you have unbound its columns and parameters, the statement handle is
available for reuse, unless you choose to drop it.
4-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
Transaction Processing
By default, a client process and connected server processes are initially in
autocommit mode, which means that each SQL statement is treated as a separate and
complete transaction, and the server commits one transaction per statement.
A commit of an unnested transaction writes all modified data to the database, releases
all locks acquired during the transaction, terminates the transaction, and returns to
autocommit mode. If the transaction is nested, any data written is internally
committed and made available to the higher (parent) transaction.
If the current transaction is not nested, a rollback discards any changes made during
the transaction, and then terminates the transaction. If the transaction is nested, only
those changes made by the nested transaction are discarded.
Nested Transactions
In manual-commit mode, transactions can be nested, for example, an application can
begin a subtransaction when another transaction or subtransaction is active. Because
only one transaction can be active at a time, the subtransaction becomes the current
active transaction while its parent transaction becomes temporarily inactive but
continues to exist. When a subtransaction completes, it is committed to its parent
transaction; it does not commit to the database until the top-level (topmost)
transaction commits. If a higher-level transaction or subtransaction rolls back, all
subtransactions beneath it also roll back.
A call to SQLFetch must be executed at the same isolation level as its corresponding
SQLExecute or SQLExecDirect call.
4-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
4 Serializable SQL_TXN_SERIALIZABLE
Isolation Levels
A UCI client program has an initial default isolation level of 0 (however, you cannot
explicitly start a transaction at this isolation level). You can change this to a different
default value by issuing an SQLSetConnectOption call. Also, in manual-commit
mode, a client can specify an isolation level for a specific transaction when issuing
the SQLTransact call that begins the transaction.
You choose which data model you want to use by setting the data model mode. In
addition, UniVerse provides a means of dynamically normalizing a nonfirst-normal-
form database. This lets you work in NF2 mode while accessing the data as if it were
normalized.
For application programmers familiar with UniVerse and its NF2 structure, NF2 mode
is the logical choice. For others who prefer to work with normalized (1NF) tables,
operating in 1NF mode is the suggested approach.
4-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
One table representing all of the singlevalued columns in the base table.
A normalized table for each of the associations of multivalued columns, and
for each unassociated multivalued column. Each association comprises the
primary key of the base table plus all multivalued columns of the
association. Each unassociated multivalued column comprises the primary
key of the base table and the column itself.
All tables appear to be first normal form and to contain only singlevalued
columns. References to the name of a base table (tablename) access only the
singlevalued columns in that table. You can access associated and
unassociated multivalued columns (in NF2 base tables) only by using
dynamic normalization (see “Dynamic Normalization and Associations” on
page 25).
SELECT * FROM tablename retrieves data from all singlevalued columns
in the base table but not from any multivalued columns.
If no column list is specified for INSERT INTO tablename, values must be
supplied for all of the base table’s singlevalued columns but not for its
multivalued columns.
The primary keys of a dynamically normalized association are always the primary
key values of the base table followed by the association key values, with the keys
separated by text marks. If the association does not have association keys, use the
@ASSOC_ROW keyword to provide a set of virtual association key values.
4-25
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch4
2/21/08
A DML statement that uses dynamic normalization can name only columns in the
association, for example, the multivalued associated columns and the primary key
columns of the base table.
SELECT Statements
Data selected from a dynamically normalized table is presented to the client as
singlevalued.
Selection criteria in the WHERE clause are used to select association rows. WHEN
clauses are not allowed with dynamic normalization because in effect the multivalued
columns have been normalized into singlevalued columns.
If an INSERT statement does not specify a list of columns into which data is to be
inserted, values must be supplied for all association columns (including the base
table’s primary key columns), in one of the following ways:
New association rows are inserted according to the positioning rule (INSERT FIRST,
INSERT LAST, etc.) specified by the ASSOC clause of the CREATE TABLE or
ALTER TABLE statement. Existing association rows cannot be assumed to be in
sorted order.
Criteria in the WHERE clause of an UPDATE statement are used to select the
association rows to be updated. WHEN clauses are not allowed with dynamic
normalization.
DELETE Statements
DELETE FROM tablename_association deletes all association rows that meet the
WHERE criteria.
For example, if you delete a row in base table tablename, the change cascades to the
related association rows in tablename_association. Likewise, if you update a primary
key value in tablename to a different value, the change also cascades to the related
association rows in tablename_association. If an INSERT statement on
tablename_association tries to create a primary key that does not exist in the base
table, or if a DELETE statement on tablename_association tries to delete a
nonexistent primary key, the action is disallowed. This phenomenon is sometimes
called implicit referential integrity because there is no code in the CREATE TABLE
statement that explicitly causes it.
4-27
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 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.2A\uci\Ch5
2/21/08
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.2A\uci\Ch5
2/21/08
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 SQLNum-
ResultCols (and so forth.) 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.2A\uci\Ch5
2/21/08
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.
Beta Beta 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.
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.
6-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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:
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:
This section discusses how the programming of a UniVerse BASIC procedure deter-
mines which type of SQL result it produces.
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.
6-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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.
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
6-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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
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.
6-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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 state-
ments, 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
"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
.
.
.
6-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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)
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 = [IBM][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 SQLClearDiagnostics, 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
6-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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 =
[IBM][SQL Client][UNIVERSE]Employee 555 does not exist
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:
ST = SQLFreeStmt (@HSTMT, SQL.CLOSE)
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, then 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).
6-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch6
2/21/08
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.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Data Types
7
Data Types and Data Type Coercion. . . . . . . . . . . . . 7-3
C Data Types Supported . . . . . . . . . . . . . . . 7-3
SQL Data Types Supported . . . . . . . . . . . . . . 7-9
Data Type Coercion . . . . . . . . . . . . . . . . 7-10
In most instances of retrieving data from the data source and storing it in a C
structure, the SQL data type source is compatible with the C data type, and no data
coercion (conversion) is required. For instance, an SQL_CHAR data type can be
stored directly into a C string. However, if the SQL data type of the source is not
compatible with the C data type, the data is coerced (converted) into a comparable
form. For instance, if an SQL VARCHAR value is stored in a numeric C field such
as SQL_C_FLOAT, UCI tries to convert the source data to numeric.
SQL_C_TINYINT char
SQL_C_STINYINT char
SQL_C_SHORT short
SQL_C_SSHORT short
Supported C Data Types
7-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
SQL_C_FLOAT float
SQL_C_DOUBLE double
SQL_C_TIME struct {
UWORD hour;
UWORD minute;
UWORD second;
}
Supported C Data Types (Continued)
SQL_C_DATE struct {
SWORD year;
UWORD month;
UWORD day;
}
SQL_C_BIT
SQL_C_BINARY
SQL_C_TIMESTAMP
SQL_C_BOOKMARK
7-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
By default, UCI server returns, for a bound column, a stripped external format. For
example, if a money column has a conversion code of MD2$, the database internally
stores the value $4.50 as the integer value 450. UCI returns this value to the appli-
cation as 4.50, that is, the correct value numerically, but stripped of all text formatting
such as currency symbols.
Also by default, dates and times are returned as C structures that preserve the full
informational content of those data types. An application can obtain dates and times
in internal format by coercing them as integers (refer to “Data Type Coercion” on
page 10) so that it can manipulate them arithmetically.
When converting data to C data types, be aware that the database supports string math
and can operate on numbers that cannot be mapped into standard C data types.
UniVerse and UniData store all data as text strings, and any attempt to convert
database numerics that exceed the limits of a C numeric data type (as specified by the
fCType parameter in an SQLBindCol call) will fail when fetching data from the
server. However, numerics can be bound as SQL_C_STRING or SQL_C_CHAR to
reduce the possibility of conversion failure.
Empty Strings
Data of all types frequently contains empty strings. If a column contains an empty
string (that is, the whole field in a singlevalued column is an empty string, or a
singlevalue in a multivalued column is an empty string), the value is returned as
follows:
LONG 0
SHORT
BYTE
DOUBLE
FLOAT
DATE SQL_BAD_DATA
0 year, 0 month, 0 day
TIME SQL_BAD_DATA
0 hour, 0 minute, 0 second
Empty String Return Values
As the table shows, an empty string maps to 0 for numeric data types and to a zero-
length string for nonnumeric data types. Because an empty string in a DATE or TIME
field cannot be mapped logically to a reasonable date or time, zeros are returned
along with a return value of SQL_SUCCESS, and the pcbValue of SQLBindCol and
SQLGetData is set to SQL_BAD_DATA.
You may want your client program to return empty string data from the data source
as null values, and to convert null values to empty strings when inserting or updating
data on the data source. To do this, do the following:
7-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
{
UWORD cDcount; /* count of the number of values in Data
array */
UWORD cStorage; /* size of Data array for which memory was
allocated */
SWORD fCType; /* the C data type pointed to by Data array
*/
SWORD fSqlType; /* the SQL data type of the columns for
parameters */
SWORD fParamType; /* input only */
SWORD ibScale; /* not currently used by the database*/
UDWORD cbColDef; /* not currently used by the database*/
UCI_DATUM Data[1]; /* array of UCI_DATUMs, one for each value
*/
} C_ARRAY
7-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
Parameter Coercion
If a numeric C-type parameter is bound to a database column of type SQL_DATE or
SQL_TIME, the numeric value is coerced to a date as the number of days before or
since December 31, 1967, or to a time as the number of seconds since midnight,
respectively. This is the reverse conversion to that performed when a numeric C data
type is bound to a column of type SQL_DATE or SQL_TIME for fetching data.
Coercing approximate numeric SQL data types into integer C data types is legal, but
in cases where the approximate numeric contains a fractional part, UCI truncates the
fractional part and returns the integer part. It also returns
SQL_SUCCESS_WITH_INFO, indicating that one or more columns of data were
truncated. If the integer part of the approximate number is too large to fit into the
designated C data type, UCI returns SQL_ERROR.
7-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
When binding columns, a data truncation error is issued after an SQLFetch call if, for
example, the server returns a value of 257 for a column bound to an
SQL_C_TINYINT. But that sort of error is based on the actual data returned for a
particular row, not on the column’s precision and scale.
Tables
The following table shows the precision, scale, and display size for supported SQL
data types for columns in UniVerse and UniData tables:
Display
SQL Data Type Precision Scalea Sizeb
SQL_CHAR From the definition. If 0 Same as
not defined, precision precision.
is 1.
SQL_SMALLINT 5 0 10
SQL_INTEGER 10 0 10
SQL_REAL 7 0 10
SQL_FLOAT 15 0 16
SQL_DOUBLE 15 0 30
SQL_DATE 10 (yyyy-mm-dd) 0 11
SQL_TIME 8 (hh:mm:ss) 0 8
a. The scale of an SQL_DECIMAL or SQL_NUMERIC data type comes from the column’s
definition; if it is not defined, the scale is 0.
b. Any FORMAT specification overrides the defaults shown in the table.
UniVerse Files
The following table shows the precision, scale, and display size for supported SQL
data types for fields in database files:
Display
SQL Data Type Precision Scalea Sizeb
SQL_CHAR From SQLTYPE or FORMAT 0 10
SQL_SMALLINT 5 0 10
SQL_INTEGER 10 0 10
SQL_REAL 7 0 10
SQL_FLOAT 15 0 10
SQL_DOUBLE 15 0 10
SQL_DATE 10 (yyyy-mm-dd) 0 10
SQL_TIME 8 (hh:mm:ss) 0 10
a. The scale of an SQL_DECIMAL or SQL_NUMERIC data type comes from the column’s
definition; if it is not defined, the scale is 0.
b. Any FORMAT specification overrides the defaults shown in the table.
7-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch7
2/21/08
Expressions
The following table shows the precision, scale, and display size for supported SQL
data types for expressions in database tables and files. By default, expressions use
only the following data types:
SQL_INTEGER 10 0 11
SQL_DOUBLE 15 0 22
SQL_DATE 10 0 10
SQL_TIME 8 0 8
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
UCI Functions
8
Function Call Summary . . . . . . . . . . . . . . . . 8-4
Variables . . . . . . . . . . . . . . . . . . . . 8-5
Search Patterns . . . . . . . . . . . . . . . . . . 8-6
Return Values . . . . . . . . . . . . . . . . . . 8-7
Error Codes . . . . . . . . . . . . . . . . . . . 8-7
Use of Hungarian Naming Conventions . . . . . . . . . . 8-8
Functions . . . . . . . . . . . . . . . . . . . . . 8-10
SQLAllocConnect . . . . . . . . . . . . . . . . . . 8-11
SQLAllocEnv. . . . . . . . . . . . . . . . . . . . 8-13
SQLAllocStmt . . . . . . . . . . . . . . . . . . . 8-15
SQLBindCol . . . . . . . . . . . . . . . . . . . . 8-17
SQLBindMvCol . . . . . . . . . . . . . . . . . . . 8-22
SQLBindMvParameter . . . . . . . . . . . . . . . . . 8-25
SQLBindParameter . . . . . . . . . . . . . . . . . . 8-27
SQLCancel . . . . . . . . . . . . . . . . . . . . 8-32
SQLColAttributes . . . . . . . . . . . . . . . . . . 8-34
SQLColumns . . . . . . . . . . . . . . . . . . . . 8-40
SQLConnect . . . . . . . . . . . . . . . . . . . . 8-44
SQLDataSources . . . . . . . . . . . . . . . . . . . 8-48
SQLDescribeCol . . . . . . . . . . . . . . . . . . . 8-51
SQLDisconnect . . . . . . . . . . . . . . . . . . . 8-54
SQLError . . . . . . . . . . . . . . . . . . . . . 8-56
SQLExecDirect . . . . . . . . . . . . . . . . . . . 8-59
SQLExecute . . . . . . . . . . . . . . . . . . . . 8-63
SQLFetch . . . . . . . . . . . . . . . . . . . . . 8-65
SQLFreeConnect. . . . . . . . . . . . . . . . . . . 8-68
SQLFreeEnv . . . . . . . . . . . . . . . . . . . . 8-70
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLFreeMem . . . . . . . . . . . . . . . . . . . . 8-72
SQLFreeStmt . . . . . . . . . . . . . . . . . . . . 8-73
SQLGetData . . . . . . . . . . . . . . . . . . . . 8-75
SQLGetFunctions . . . . . . . . . . . . . . . . . . 8-79
SQLGetInfo . . . . . . . . . . . . . . . . . . . . 8-83
SQLNumParams . . . . . . . . . . . . . . . . . . . 8-91
SQLNumResultCols . . . . . . . . . . . . . . . . . . 8-93
SQLParamOptions . . . . . . . . . . . . . . . . . . 8-95
SQLPrepare . . . . . . . . . . . . . . . . . . . . 8-98
SQLRowCount . . . . . . . . . . . . . . . . . . . 8-102
SQLSetConnectOption . . . . . . . . . . . . . . . . . 8-104
SQLSetParam . . . . . . . . . . . . . . . . . . . . 8-110
SQLTables . . . . . . . . . . . . . . . . . . . . . 8-112
SQLTransact . . . . . . . . . . . . . . . . . . . . 8-116
SQLUseCfgFile . . . . . . . . . . . . . . . . . . . 8-120
This chapter is a reference for UCI function calls, listed in alphabetical order. The
following diagram illustrates a typical function reference page.
Syntax
RETCODE SQLFunction (variables) Function syntax
Input Variables
Arguments used
Output Variables
Description
Information about how to use the function. Detailed description of usage
Return Values
SQL_SUCCESS
Return values and
SQLSTATE Values SQLSTATE values
S1001 Memory allocation failure.
Example
#include "UCI.h"
Example showing how
to use function
8-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Use Functions
Initializing SQLAllocConnect
SQLAllocEnv
SQLAllocStmt
SQLConnect
SQLPrepare
SQLSetConnectOption
SQLUseCfgFile
Use Functions
Disconnecting SQLCancel
SQLDisconnect
SQLFreeConnect
SQLFreeEnv
SQLFreeStmt
Functions and Their Uses (Continued)
Variables
In the following syntax the variable henv is the environment handle returned from
SQLAllocEnv, and the variable phdbc is a pointer to where the connection handle is
to be stored. Names of return variables, input variables, and output variables are user-
defined.
All calls use handles that represent a pointer to an underlying data structure. The data
structures are defined by the UCI.h include file. Handles form a hierarchy as follows:
Argument Comment
HDBC (void *)
HENV (void *)
HSTMT (void *)
Arguments in UCI Calls
8-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Argument Comment
PTR (void *)
Search Patterns
Information returned by a function can, in some cases, be controlled by a search
pattern that you pass as an argument to that function. For example, SQLColumns
returns a result set describing the columns from the tables specified in the search
pattern. Besides the standard alphanumeric characters, you can use the following
characters as wildcards:
Character Description
As an example, to cause SQLColumns to return the columns from all tables that are
named REF_TBLx, use the search pattern REF\_TBL_. The first underscore, which
is preceded by a backslash, is interpreted as a literal backslash, whereas the second
underscore is interpreted as any single character. Note that using a search pattern of
% represents an empty pointer and, in this example, returns all tables.
Return Values
UCI functions return a value to the status variable. Return values are the following:
SQL_NO_DATA_FOUND All rows from the result set have been retrieved.
Return Values
Error Codes
Any UCI function call can generate errors. Use the SQLError function after any other
function call for which the returned status indicates an error condition. UCI follows
the guidelines dictated by the Microsoft ODBC specification in returning these error
codes. For a list of UCI function error codes, see SQLError later in this chapter,
Appendix A, “Error Codes” for more detail.
8-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Prefix Meaning
c count of
h handle to
i index of
p pointer to
rg range (array) of
Tag Meaning
b byte
env environment
par parameter
stmt statement
sz null-terminated string
For example, hdbc is a handle for a database connection, ipar is an index parameter,
pib is a pointer to an index byte, and rgb is a range array of bytes.
8-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Functions
UCI function calls are presented on the following pages in alphabetical order. Each
function is described in terms of syntax, input and output variables, description,
return values, and SQLSTATE values. Some functions also have an example.
Programmatic SQL statements are case-sensitive. You must code all SQL statement
names (such as CREATE TABLE, SELECT, and INSERT), SQL keywords (such as
INTEGER, WHERE, FROM, and GROUP BY), and database-specific keywords
(such as ROWUNIQUE and UNNEST) in uppercase letters. You must code identi-
fiers such as table and column names to match the format of the identifier as
originally defined.
Note: An asterisk (*) following a Type entry in a table of input or output variables
indicates that the argument is the address of a variable that is a pointer. A double
asterisk (**) indicates that the argument is a pointer to a pointer.
SQLAllocConnect
SQLAllocConnect allocates memory for a connection handle within the environment
identified by henv. You must issue a call to SQLAllocConnect before you try to
connect to a server.
Syntax
RETCODE SQLAllocConnect (henv, phdbc)
Input Variable
The following table describes the input variable:
Output Variable
The following table describes the output variable:
Description
Use this function to create a connection environment to connect to a particular data
source. SQLAllocConnect stores the environment handle in phdbc.
One environment can have several connection handles, one for each data source.
SQLAllocConnect 8-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values:
SQLSTATE Description
SQLAllocEnv
SQLAllocEnv allocates memory for an environment handle and initializes the
interface for use by the client application. This must be the first call issued before any
other UCI function.
Syntax
RETCODE SQLAllocEnv (phenv)
Output Variable
The following table describes the output variable:
Description
Use this function to allocate memory for an environment. The address is stored in
phenv.
Return Values
SQL_SUCCESS
SQL_ERROR
SQLSTATE Values
No SQLSTATE can be returned on an error, because there is no valid henv for the
SQLError call. If the call fails, the failure is caused by one of the following:
SQLAllocEnv 8-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLAllocStmt
SQLAllocStmt allocates memory for a statement handle and associates the statement
handle with the connection specified by hdbc.
Syntax
RETCODE SQLAllocStmt (hdbc, phstmt)
Input Variable
The following table describes the input variable.
Argumen
Type t Description
Output Variable
The following table describes the output variable.
Description
A statement handle represents a single SQL statement and holds all information that
UCI needs to describe results, return data rows, and so forth.
SQLAllocStmt 8-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values.
Value Description
SQLBindCol
SQLBindCol assigns storage for loading data from a column in a result set and
specifies any data conversion to be performed.
Syntax
RETCODE SQLBindCol (hstmt, icol, fCType, rgbValue, cbValueMax, pcbValue)
Input Variables
The following table describes the input variables.
UWORD icol Column number of the result set, numbered left to right
starting at 1. This value must be from 1 through the
number of columns returned in an operation.
SWORD fCType C data type into which to convert the incoming data.
See C Data Types Supported in Chapter 7, “Data
Types,” for a complete list of valid C data types.
PTR rgbValue Pointer to the storage area allocated to hold the result
set. For an SQL_C_STRING data type, this should be
the address of the structure’s text member, and
pcbValue should be the address of the length part of the
structure.
SQLBindCol 8-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
For all other data types, this contains the size of the
application data type specified.
SQLBindCol Input Variables (Continued)
Description
Use this function to tell UCI where to return the results of an SQLFetch call.
SQLBindCol defines where data values retrieved from the database by SQLFetch are
to be stored in the application and specifies the data conversion (fCType) to be
performed on the fetched data.
SQLBindCol is designed for use on singlevalued data primarily. If you use it for a
column and at SQLFetch time that column is found to contain multivalues, only the
first value is returned, coerced into the requested data type. A return code of
SQL_SUCCESS_WITH_INFO is also returned with an SQLSTATE of IM981 to
indicate that the multivalued data was truncated to the first value. Successive calls to
SQLGetData fetch successive values for that column. However, this approach is
much less efficient than using SQLBindMvCol, which is the recommended method.
Using both binding methods for the same hstmt is permitted, and may in fact be
necessary to deal with those queries that generate a mix of single-valued and
multivalued data.
Note: Issuing this call does not fetch data from the database, but only performs the
setup for SQLFetch. SQLBindCol has no effect until SQLFetch is used.
Normally you call SQLBindCol once for each column of data in the result set. Issuing
SQLFetch moves data from the result set at the data source to the variables specified
in the SQLBindCol call, overwriting any existing contents.
Data is converted from the data source to the data type requested by the SQLBindCol
call, if possible. If data cannot be converted to fCType, an error occurs and the column
is not bound. See C Data Types Supported in Chapter 7, “Data Types,” for
information about data conversion types.
Values are returned only for bound columns when a call to SQLFetch is issued.
Unbound columns are ignored and are not accessible unless you call SQLGetData.
For example, if a SELECT statement returns three columns, but you called
SQLBindCol for only two columns, data from the third column is accessible to your
program only by using SQLGetData on the column. If you bind more variables than
there are columns in the result set, an error is returned. If you bind no columns and
SQLFetch is issued, the cursor advances to the next row of results and no program
variables are loaded with data.
Do not use SQLBindCol with SQL statements that do not produce result sets.
Note: Be careful when executing a new SQL statement with a statement handle that
already has columns bound with SQLBindCol. If you do not use the SQLFreeStmt
call with the SQL_UNBIND option first, UCI assumes that the previous column
bindings are still in effect. If the new SQL statement generates fewer columns than
the previous SQL statement, the new SQL statement fails with an SQLSTATE of
S1002, indicating that the wrong number of columns were bound. This error might
also lead to data conversion errors if the columns for the new SQL statement cannot
be converted according to the previous bindings.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLBindCol 8-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1002 Illegal column number. The value of icol is greater than the number of
columns in the result set or is less than 1.
Example
This program fragment determines the number of columns generated from the
execution of an SQL statement and, if there are results, binds up to 10 columns to a
column array.
Note: The code to allocate environments, connections, and the like is not shown here.
#define MAXCOLS 10
#define COLUMN_WIDTH 132
#include <stdio.h>
#include "UCI.h"
struct column
{
char column_buffer [COLUMN_WIDTH];
SDWORD column_outlen;
};
SWORD numcols;
HSTMT hstmt;
struct column columns[10]; /* Max of 10 columns */
main()
{
int indexs;
/* All allocation, connection, etc., code goes here */
SQLExecDirect ( hstmt, "SELECT * FROM MYTABLE");
/* Get the number of columns produced. If there are any,
* bind them all to character strings in the column
* array. */
SQLNumResultCols (hstmt, &numcols);
if (numcols)
{
for (indexs = 1; indexs <= MAXCOLS; indexs ++)
{
SQLBindCol(hstmt, indexs,
SQL_C_CHAR,
&columns[indexs].column_buffer,
COLUMN_WIDTH,
&columns[indexs].column_outlen);
}
}
}
SQLBindCol 8-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLBindMvCol
SQLBindMvCol is a database-specific extension of the SQLBindCol function. It
simplifies the fetching of multivalued data by normalizing it into arrays of C program
variables allocated by UCI. UCI allocates storage based on the number of values
returned, so you do not need to know how much storage to allocate in advance.
Syntax
RETCODE SQLBindMvCol (hstmt, icol, fCType, pCArray)
Input Variables
The following table describes the input variables.
UWORD icol Column number of the result set, numbered left to right
starting at 1.
SWORD fCType The data type for storing the data, in the UCI_DATUM
union.
Description
This extension to SQLBindCol allows a simple model to be used in dealing with
multivalued columns. UCI allocates storage for these values and returns addresses to
the application in the form of an array.
The user application specifies the application data type into which to convert the data.
UCI allocates a data structure for each value it encounters in a particular column, and
returns to the application the address of that array of values. As the application need
not be concerned with allocating storage before fetching a row of data, there is no
cbValueMax parameter in this call.
You can also use SQLBindMvCol with singlevalued data whenever you want UCI to
allocate storage.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1002 Illegal column number. The value of icol specified is greater than the number
of columns in the result set.
SQLBindMvCol 8-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Example
The following fragment of pseudocode shows how to use this call to print some
results. The example assumes a two-column result set, with the first column being
single-valued, and the second column being a multivalued column containing
integers.
#include "UCI.h"
UCHAR col1buff[100];
HSTMT hstmt;
SDWORD col1size;
UWORD nv;
RETCODE status;
C_ARRAY *pCArray;
UCI_DATUM *ud;
SQLExecDirect (hstmt, "SELECT COL1, COL2 FROM MYTABLE");
SQLBindCol (hstmt, 1, SQL_C_CHAR, col1buff, 100, &col1size);
SQLBindMvCol (hstmt, 2, SQL_C_INTEGER, &pCArray);
while ((status = SQLFetch(hstmt)) == SQL_SUCCESS)
{
printf(" %s\n ", col1buff);
nv = pCArray->cDcount;
ud = pCArray->Data;
while (nv--)
{
if (ud->fIndicator == SQL_NULL_DATA)
{
printf("\t NULL \n");
}
else if (ud->fIndicator == SQL_BAD_DATA)
{
printf("\t Data could not be converted \n");
}
else
{
printf("\t %d\n", ud->uValue.int);
}
ud++;
}
}
SQLFreeMem (*pCArray);
SQLBindMvParameter
SQLBindMvParameter is a database-specific extension of the SQLBindParameter
function. It allows an application to write a multivalued column from an array of C
variables (which is the form read by SQLFetch after SQLBindMvCol has been
called).
Syntax
RETCODE SQLBindMvParameter (hstmt, ipar, pCArray)
Input Variables
The following table describes the input variables.
Description
This function allows data to be used in the form returned by SQLBindCol anywhere
in the SQL grammar that a parameter marker can be used. The array of data of type
fCType is processed by UCI into a dynamic array in a form that the database can use
internally—the reverse of how a multivalued dynamic array is processed into a C
array by SQLBindCol.
SQLBindMvParameter 8-25
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
The pCArray argument is the address of an array of C_ARRAY structures that you
must manage in your application program. If the memory is allocated from system
memory with the malloc command, be sure that you free that memory when you no
longer need it.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1093 ipar was less than 1 or greater than the number of parameters in the SQL
statement.
SQLBindMvParameter SQLSTATE Values
SQLBindParameter
SQLBindParameter binds an application buffer to a parameter marker in an SQL
statement. It is functionally similar to the SQLSetParam call in the ODBC 1.0
specifications. SQLSetParam has also been provided in UCI for compatibility.
Syntax
RETCODE SQLBindParameter (hstmt, ipar, fParamType, fCType, fSqlType,
cbColDef, ibScale, rgbValue, cbValueMax, pcbValue)
Input Variables
The following table describes the input variables.
SWORD fCType C data type from which to convert the incoming data. See C
Data Types Supported in Chapter 7, “Data Types,” for a
complete list of valid C data types supported.
SWORD fSqlType SQL data type of the parameter. For more information, see
“The fSqlType Parameter” on page 29.
SQLBindParameter Input Variables
SQLBindParameter 8-27
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
UDWORD cbColDef Not currently used, but reserved for precision of the column
or expression of the associated parameter marker. You must
set it to SQL_UV_DEFAULT_PARAMETER. For more
information, see “The cbColDef and ibScale Parameters” on
page 29.
SWORD ibScale Not currently used, but reserved for scale of the column or
expression of the associated parameter marker. You must set
it to SQL_UV_DEFAULT_PARAMETER. For more
information, see “The cbColDef and ibScale Parameters” on
page 29.
PTR rgbValue Pointer to the buffer for the parameter’s data. If you are
using SQLParamOptions, rgbValue points to an array of
data values.
SDWORD * pcbValue Pointer to the buffer holding the parameter’s length. If you
are using SQLParamOptions, pcbValue points to an array
of parameter lengths. For more information, see “The
pcbValue Parameter” on page 30.
SQLBindParameter Input Variables (Continued)
Description
Use this function when parameter markers (represented by the ? character) are used
as part of the SQL statement syntax. This call identifies the program variables that
are used to hold values for each parameter marker in the statement. When you issue
an SQLExecDirect or an SQLExecute call, UCI extracts the value now in place for
each marker, checks for any data conversion errors, and delivers the values to the
server, where they are inserted into the SQL statement. The statement is then
executed.
You need to call SQLBindParameter only once for each marker. From that point on
UCI remembers where to find each marker and what its characteristics are.
fSqlType
Parameter Description
Generally, fSqlType is used to ensure that the data presented to UCI for the parameter
marker is compatible with the data type of the marker. For example, if the application
specifies a numeric SQL type for a marker, and the data presented at execution is a
text string rather than a numeric string, UCI returns SQLSTATE 22005.
SQLBindParameter 8-29
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1093 ipar is less than 1 or greater than the number of parameters in the SQL
statement, or fParamType is not SQL_PARAM_INPUT, or cbColDef or
ibScale is not SQL_UV_DEFAULT_PARAMETER.
07006 The fCType data type cannot be converted to the fSqlType data type.
SQLBind Parameter SQLSTATE Values
SQLBindParameter 8-31
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLCancel
SQLCancel cancels the processing of the current SQL statement and discards any
pending results. SQLCancel is equivalent to SQLFreeStmt with the SQL_CLOSE
option specified.
Syntax
RETCODE SQLCancel (hstmt)
Input Variable
The following table describes the input variable.
Description
This function closes any open cursor for the statement handle supplied and discards
pending results at the data source. hstmt can be reopened by executing it again, using
the same or different parameters.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1010 Function sequence error. An attempt was made to cancel an hstmt while
another hstmt was still executing.
SQLCancel SQLSTATE Values
SQLCancel 8-33
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLColAttributes
SQLColAttributes returns more extensive column attribute information than
SQLDescribeCol.
Syntax
RETCODE SQLColAttributes (hstmt, icol, fDescType, rgbDesc, cbDescMax,
pcbDesc, pfDesc)
Input Variables
The following table describes the input variables.
Output Variables
The following table describes the output variables.
SWORD * pcbDesc Pointer to the location used to hold the total number of
bytes available to return in rgbDesc.
SDWORD * pfDesc Pointer to the location used to hold the description infor-
mation for numeric descriptor types.
SQLColAttributes Output Variables
Description
Depending on the attribute requested, SQLColAttributes can return the result as
either a character string or an integer value.
You can call SQLColAttributes only after the statement has been prepared by either
SQLPrepare or SQLExecDirect; before either of these two calls, the information is
not available. If the statement is an SQL procedure call, column information is not
available until after the statement is executed. Integer information is returned in
pfDesc as a 32-bit value.
SQLColAttributes 8-35
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
All other formats are returned in rgbDesc (the use of which depends on fDescType).
The following table shows where each result is returned.
Informatio
n is
returned
If fDescType is... in... Description
Informatio
n is
returned
If fDescType is... in... Description
SQLColAttributes 8-37
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Informatio
n is
returned
If fDescType is... in... Description
The values returned for some of these column attributes are of limited use to database
applications. For example, in databases constrained to fixed-length columns, the
precision of a column is typically of fundamental importance, and can be viewed as
an internal constraint on the data stored in that column. The database does not enforce
such constraints, so although a column may be defined as CHAR(30), the database
does not prohibit entry of more than 30 characters. Likewise, the attributes
SQL_COLUMN_DISPLAY_SIZE, SQL_COLUMN_PRECISION,
SQL_COLUMN_SCALE, and SQL_COLUMN_LENGTH are only approximations
and do not place constraints on the data that the application can insert.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLSTATE values.
SQLSTATE Description
S1000 General error for which there is no specific SQLSTATE code defined.
S1002 Illegal column number. The value of icol is less than 1 or is greater than
the number of columns in the result set.
S1009 rgbDesc or pcbDesc is null, or the result returned will be an integer and
pfDesc is null.
01004 The rgbDesc buffer was too small. The pcbDesc parameter holds the
length of the untruncated value. The string in rgbDesc is truncated to
cbDescMax – 1 bytes. SQL_SUCCESS_WITH_INFO is returned as the
status code.
24000 hstmt has no result set pending. There are no columns to describe.
SQLColAttributes SQLSTATE Values
SQLColAttributes 8-39
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLColumns
SQLColumns returns a result set listing the columns matching the search patterns.
Syntax
RETCODE SQLColumns (hstmt, szTableQualifier, cbTableQualifier, szTableOwner,
cbTableOwner, szTableName, cbTableName, szColumnName, cbColumnName)
Input Variables
The following table describes the input variables.
Description
This function returns a result set in hstmt as a cursor of 13 columns describing those
columns found by the search pattern (refer to SQLTables). 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.
SQLColumns 8-41
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
The application is responsible for binding variables for the output columns and
fetching the results using SQLFetch. The result set contains one column in addition
to those columns listed in the ODBC 2.0 interface description. This is the
MULTI_VALUE column, which returns S for single-valued columns and M for
multivalued columns.
If no search criteria are specified, the SQL statement executed by SQLColumns is:
SELECT A.TABLE_SCHEMA, OWNER, A.TABLE_NAME, COLUMN_NAME,
NULL COL.HDG 'Data Type' AS DATA_TYPE_NULL,
DATA_TYPE COL.HDG 'Type Name' AS TYPE_NAME,
NUMERIC_PRECISION,
CHAR_MAX_LENGTH, NUMERIC_SCALE, NUMERIC_PREC_RADIX,
EVAL B.'IF NULLABLE="NO" THEN 0 ELSE 1' COL.HDG 'Nullable'
AS NULLABLE_UV, B.REMARKS, MULTI_VALUE
FROM UNNEST UV_TABLES ON COLUMNS A, UV_COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME
AND A.COLUMNS = B.COLUMN_NAME
ORDER BY 1, 2, 3;
If search criteria are specified, they are added as part of the SQL WHERE clause.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLColumns 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.
42000 Syntax error or access violation. This can happen for a variety of reasons.
The native error code returned by the SQLError call indicates the specific
database error that occurred.
SQLColumns SQLSTATE Values
SQLColumns 8-43
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLConnect
SQLConnect connects to a data source, which can be either a local or a remote
UniVerse database. You cannot use SQLConnect inside a transaction.
Syntax
RETCODE SQLConnect (hdbc, szDSN, cbDSN, szSchema, cbSchema)
Input Variables
The following table describes the input variables.
Description
The server uses the supplied data source name (szDSN) as a key to the UCI
configuration file uci.config, which maps the name to a specific database account or
schema on a specific system. A skeleton version of this file, shipped with UCI, allows
connection to the local host using the name localuv. To add remote database entries,
the system administrator must edit this configuration file. For more information
about the UCI configuration file, see Chapter 3, “Configuring UCI.”
The schema name in the UV_SCHEMA table to which the server will attach
itself
The account identifier (szSchema) must point to a directory that has been set up to
run UniVerse.
If the string does not begin with / (slash) or, on Windows systems, \ (backslash), both
the UV_SCHEMA table and the UV.ACCOUNT file are examined. If the name is
unambiguous (that is, it is defined in only one file or has the same definition in both
files), it is used. If it is ambiguous, it is rejected.
You can also specify certain connect time options with the SQLSetConnectOption
call, and these take effect for the duration of the connection only.
If the DSN is not the local host, the client passes the requested user name, password,
and schema/account name through to the server. The server verifies the user
name/password combination with the operating system and if that is valid, verifies
that the requested schema is a valid schema or valid account on the server. Finally,
the NLS map and locale settings, if set, are sent to the server. If any of these steps
fails, an error is returned, indicating that the server rejected the connection request.
You must establish all connections before you can start a transaction.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLConnect 8-45
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSTATE Values
The following table describes the SQLConnect SQLSTATE values.
SQLSTATE Description
IM002 The specified data source was not found in the UCI configuration file.
IM982 A user identification is required to connect to this data source. This user
must be found in the password file at the server.
IM984 UCI does not allow connections to data sources other than UniVerse.
IM999 A network type other than TCP/IP or LAN Manager is specified for the
data source.
S1000 General error for which no SQLSTATE code has been defined.
08001 The connection could not be established. See “Error Codes” for more
information.
Error Codes
An SQLSTATE return of 08001 or 08004 indicates that, for one of several reasons,
the connection to the server could not be established. In such cases, further infor-
mation can be obtained by issuing a call to SQLError and examining the native error
code parameter. The most common reasons for a connect failure are as follows:
Code Description
80011 The user name specified could not be found in the server system’s password
file.
81002 The server name specified in the data source was not found in the
unirpcservices file on the server.
81011 The host specified in the uci.config file for the data source could not be found
on the network.
81013 The unirpcd daemon on the UNIX server, or the unirpc service on the
Windows server, could not open the unirpcservices file in the server’s
unishared directory.
81014 The service requested by the client could not be located or run by the server.
Check the data source entry in the uci.config file to ensure that the service
name in the entry is a valid entry in the unirpcservices file on the server.
81016 The unirpcd daemon on the UNIX server, or the unirpc service on the
Windows server, is not running. Start the daemon or service on the server.
930098 The server could not create the helper process for the connection.
930133 szSchema was not an absolute pathname and was not found to be either a
valid account or a schema.
SQLConnect 8-47
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLDataSources
SQLDataSources returns information about data sources.
Syntax
RETCODE SQLDataSources (henv, fDirection, szDSN, cbDSNMax, pcbDSN,
szDescription, cbDescriptionMax, pcbDescription, DBMSType)
Input Variables
The following table describes the input variables.
Output Variables
The following table describes the output variables.
Description
An application can call SQLDataSources multiple times to retrieve all data source
names. When there are no more data source names, UCI returns
SQL_NO_DATA_FOUND. If SQLDataSources is called with SQL_FETCH_NEXT
immediately after it returns SQL_NO_DATA_FOUND, it returns the first data source
name.
SQLDataSources 8-49
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_ERROR
SQL_NO_DATA_FOUND
SQLSTATE Values
When SQLDataSources returns SQL_ERROR or SQL_SUCCESS_WITH_INFO,
you can call SQLError to get the associated SQLSTATE value. Common SQLSTATE
values returned are:
SQLSTATE Description
01004 Data truncated. Either the data source name buffer or the configuration
information buffer is too small. Use the other arguments to determine
which one is too small.
IM998 UCI configuration file error. Either the configuration file does not exist, or
an error was found in the file.
SQLDescribeCol
SQLDescribeCol returns limited descriptive information (column name, data type,
precision, scale, and nullability) about a specified column. This call can be used only
after the statement has been prepared by an SQLPrepare or SQLExecDirect call.
The SQLColAttributes function provides access to more information than
SQLDescribeCol.
Syntax
RETCODE SQLDescribeCol (hstmt, icol, szColName, cbColNameMax,
pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable)
Input Variables
The following table describes the input variables.
SQLDescribeCol 8-51
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Output Variables
The following table describes the output variables.
SWORD * pfSqlType The SQL data type of the column. See SQL Data
Types Supported in Chapter 7, “Data Types,” for a
list of SQL data types that can be returned.
Description
The information returned by SQLDescribeCol is a subset of the information returned
by SQLColAttributes and is of limited use to database applications. In first-normal-
form databases constrained to use fixed-length columns, the precision of a column is
of fundamental importance to the database and can be viewed as an internal CHECK
constraint on the data coming into the column. However, the database, being more
flexible, has no need to enforce such constraints, and although a column may be
defined as CHAR(30), the database does not prevent a user application from entering
longer strings.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLDescribeCol SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1002 The value in icol is greater than the number of columns in the result set.
S1010 Function sequence error. SQLDescribeCol was called before calling either
SQLPrepare or SQLExecDirect for hstmt.
S1090 The value specified in cbColNameMax is less than or equal to 0.
01004 The szColName buffer was too short for the name to be returned and the
result was truncated (SQL_SUCCESS_WITH_INFO).
24000 The SQL statement associated with hstmt did not return a result set.
SQLDescribeCol SQLSTATE Values
SQLDescribeCol 8-53
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLDisconnect
SQLDisconnect closes the connection associated with a particular connection handle.
You cannot use SQLDisconnect inside a transaction.
Syntax
RETCODE SQLDisconnect (hdbc)
Input Variable
The following table describes the input variable.
Description
An application must explicitly issue a COMMIT or ROLLBACK statement for any
active transactions before attempting to issue an SQLDisconnect call. If an
application should terminate either normally or abnormally with transactions still
active, an implicit ROLLBACK statement is executed at the server.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLDisconnect SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1010 Function sequence error. The connection handle has a statement handle
that is currently being executed by the server.
01002 An error occurred during the disconnect, but the connection has been
broken (SQL_SUCCESS_WITH_INFO).
SQLDisconnect 8-55
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLError
SQLError returns error information and status from the server.
Syntax
RETCODE SQLError (henv, hdbc, hstmt, szSqlState, pfNativeError, szErrorMsg,
cbErrorMsgMax, pcbErrorMsg)
Input Variables
The following table describes the input variables.
Output Variables
The following table describes the output variables.
UCHAR * szErrorMsg Pointer to storage for error text (storage for 256
characters is recommended).
Description
Typically, an application calls SQLError whenever a previous call returns
SQL_ERROR or SQL_SUCCESS_WITH_INFO, but it can be used after any call.
Error status information can be retrieved for an error associated with an environment,
a connection, or a statement as follows:
To retrieve errors
associated with... Do this...
Statement Pass the statement’s hstmt (any henv and hdbc arguments are
ignored). The error status of the ODBC function most recently
called with hstmt is returned.
Error Status Information
Because more than one error or warning message can be posted for a single UCI call,
an application should call SQLError until the function returns the value
SQL_NO_DATA_FOUND. For each error, SQL_SUCCESS is returned and the error
is removed from the error list.
SQLError 8-57
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
[IBM] [UniVerse] . . .
[IBM] [RPC] . . .
All errors for a given handle are removed when SQLError is called repeatedly for that
handle or when that handle is used in a subsequent function call. However, errors for
a given handle are not removed by a call to a function using an associated handle of
a different type.
SQLSTATE values are always five characters long, so szSqlState must point to
storage for a maximum of six characters. Error messages vary widely in length, so
the user application must allocate storage and inform UCI how much storage has
been allocated via the cbErrorMsgMax parameter. It is recommended that at least 256
characters be reserved for error messages. For example:
#define cbErrorMsgMax 256
SCHAR szSqlState[6];
SCHAR szErrorMsg[ cbErrorMsgMax ];
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQL_NO_DATA_FOUND
SQLSTATE Values
The SQLError function does not post errors for itself. However, if an error message
to be returned is larger than the buffer allocated to store it, the value
SQL_SUCCESS_WITH_INFO is returned from the SQLError call, and the buffer
contains truncated error text.
SQLExecDirect
SQLExecDirect executes a preparable SQL statement or procedure call using the
current values of any parameter markers that are set up for the statement.
Syntax
RETCODE SQLExecDirect (hstmt, szSqlStr, cbSqlStr)
Input Variables
The following table describes the input variables.
Description
This function both prepares and executes an SQL statement or procedure call. It
differs from SQLExecute in that SQLExecDirect does not require a call to
SQLPrepare. Use SQLExecDirect as the easiest way to execute an SQL statement or
procedure when you do not need to execute it repeatedly.
The SQL statement or procedure call can contain parameter markers, which must be
defined to UCI by an SQLBindParameter call before issuing SQLExecDirect. Before
the SQL statement or procedure is executed, the current values of the markers are
delivered to the server. Any data conversion problems caused by erroneous parameter
marker values are detected when this call is given.
SQLExecDirect 8-59
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
If the SQL statement is a SELECT statement or procedure call, there could be data
that can be retrieved by SQLFetch as a result of executing SQLExecDirect. You can
issue a call to SQLNumResultCols to determine if any result columns were produced
by executing the SQL statement or procedure.
Parameter Description
procedure Name of the procedure. If this name contains characters other than letters
or numbers, enclose the name in double quotation marks. To embed a
single quotation mark in the procedure name, use two consecutive double
quotation marks.
parameter Either a liternal value or a parameter marker that indicates where to insert
values to send to or receive from the data source. Programmatic SQL uses
a ? (question mark) as a parameter marker.
You cannot use SQLBindMvParameter to bind parameter marks used
in a call statement.
Use parameters only if the procedure is a subroutine. The number and
order of parameters must correspond to the number and order of the
subroutine arguments.
argument Any valid keyword, literal, or other token you can use in a database
command line.
call Parameters
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLExecDirect SQLSTATE values.
SQLSTAT
E Description
IA000 An SQL statement was not executed because it contains the EXPLAIN
keyword. The EXPLAIN output is returned as error message text (see
SQLError).
S0001 Table or view already exists. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code
argument of the SQLError call.
S0002 Table or view not found. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code
argument of the SQLError call.
S0021 Column already exists. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code
argument of the SQLError call.
S0022 Column not found. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code
argument of the SQLError call.
S1000 General error for which no specific SQLSTATE code has been defined.
S1010 Function sequence error. The hstmt specified is currently executing an SQL
statement.
SQLExecDirect 8-61
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSTAT
E Description
07001 Not all parameter markers in the SQL statement have been specified with
SQLBindParameter.
21S01 Insert value list does not match the value list.
21S02 Number of columns in derived table does not match the column list.
22001 A parameter marker value was sent, but fractional truncation occurred.
22005 A value in a parameter marker is incompatible with the SQL data type of
that marker.
24000 Invalid cursor state. Results are still pending from the previous SQL
statement. Use SQLCancel to clear the results.
40001 An SQL statement with the NOWAIT keyword was not executed because
it encountered a lock conflict. The application may choose to sleep and
retry the operation a few times before giving up.
42000 Syntax error or access violation. This can happen for a variety of reasons.
The native error code returned by the SQLError call indicates the specific
database error that occurred.
SQLExecDirect SQLSTATE Values (Continued)
SQLExecute
SQLExecute executes an SQL statement that has been prepared with SQLPrepare,
using the current values of any parameter markers.
Syntax
RETCODE SQLExecute (hstmt)
Input Variable
The following table describes the input variable.
Description
This function is commonly used for such operations as inserting multiple rows into
an SQL table.
You must call SQLPrepare 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 or SQLSetParam call
for each marker in the SQL statement before calling SQLExecute. After you load the
parameter marker variables with data to send to the data source, you can issue a call
to SQLExecute. 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 SQLSetParam calls for the parameter markers.
SQLExecute 8-63
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLExecute SQLSTATE values.
SQLSTATE Description
IA000 An SQL statement was not executed because it contains the EXPLAIN
keyword. The EXPLAIN output is returned as error message text (see
SQLError).
S1000 General error for which no specific SQLSTATE code has been defined.
S1010 Function sequence error. Either the SQL statement has not been prepared,
or there is an SQL statement already executing on the statement handle.
07001 Not all parameter markers in the SQL statement have been bound with
SQLBindParameter.
22005 A value in a parameter marker is incompatible with the SQL data type of
that marker.
24000 Invalid cursor state. Results are still pending from the previous SQL
statement. Use SQLCancel to clear the results.
40001 An SQL statement with the NOWAIT keyword was not executed because
it encountered a lock conflict. The application may choose to sleep and
retry the operation a few times before giving up.
SQLExecute SQLSTATE Values
SQLFetch
SQLFetch returns the next row of data from a result set. Column data for all columns
specified in a preceding SQLBindCol call is returned into the variables that were
bound to the columns in the result set. If a column was bound with SQLBindMvCol,
UCI allocates a correctly sized C_ARRAY structure and returns its address in the
pCArray argument of the SQLBindMvCol call for each column.
Syntax
RETCODE SQLFetch (hstmt)
Input Variable
The following table describes the input variable.
Description
This function retrieves the next row’s column values from the result set and puts them
into the variables specified with SQLBindCol or SQLBindMvCol. If the data was
bound by a call to SQLBindCol and the data returned from the server is found to be
multivalued, only the first value is returned in the bound parameter, along with a
status of SQL_SUCCESS_WITH_INFO. Call SQLGetData to get subsequent
values.
SQLFetch performs any required data conversions (see C Data Types Supported in
Chapter 7, “Data Types,” for details). SQL_SUCCESS_WITH_INFO is returned if
numeric data is truncated or rounded when converting SQL values to database values.
Each SQLFetch call logically advances the cursor to the next row in the result set (the
database supports only forward scrolling cursors). When there is no more data to
retrieve, SQL_NO_DATA_FOUND is returned.
SQLFetch 8-65
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Use SQLFetch only when a result set is pending at the data source.
Transactional Notes
Two rules govern the fetching of data in manual-commit mode:
You must fetch data at the same transaction isolation level as that at which
the original SELECT statement was executed:
SQLTransact ( SQL_HULL_HENV, hdbc,
SQL_BEGIN_TRANSACTION + SQL_TXN_READ_COMMITTED);
SQLBindCol ( hstmt, 1, ...);
SQLBindCol ( hstmt, 2, ...);
SQLExecDirect ( hstmt, "SELECT COL1, COL2 FROM TABLE"
);
.
.
.
SQLTransact ( SQL_HULL_HENV, hdbc,
SQL_BEGIN_TRANSACTION);
SQLFetch ( hstmt );
The previous code sequence is legal. The following sequence fails because the
SELECT statement is executed in a transaction started at isolation level
READ_COMMITTED, whereas the SQLFetch is executed from a higher transaction
isolation level (REPEATABLE_READ). Because the locking strategy for the
SELECT statement is determined when SELECT is executed, trying to fetch data at
a higher isolation level is not allowed because the data would be fetched using the
lower level.
SQLTransact ( SQL_HULL_HENV, hdbc,
SQL_BEGIN_TRANSACTION + SQL_TXN_READ_COMMITTED);
SQLBindCol ( hstmt, 1, ...);
SQLBindCol ( hstmt, 2, ...);
SQLExecDirect ( hstmt, "SELECT COL1, COL2 FROM TABLE"
);
.
.
.
SQLTransact ( SQL_HULL_HENV, hdbc,
SQL_BEGIN_TRANSACTION + SQL_TXN_REPEATABLE_READ);
SQLFetch ( hstmt );
Once COMMIT or ROLLBACK is issued for a transaction in which a
SELECT statement was executed, no further fetches from that cursor are
permitted because the cursor has been closed by COMMIT or ROLLBACK.
Attempting to fetch from the closed cursor returns an SQLSTATE of 24000.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQL_NO_DATA_FOUND
SQLSTATE Values
The following table describes the SQLFetch SQLSTATE values.
SQLSTATE Description
IM981 One value was returned from multivalued data bound by SQLBindCol.
The condition returns SQL_SUCCESS_WITH_INFO.
S1000 General error for which no specific SQLSTATE code has been defined.
S1002 Invalid column number. icol is 0 or is greater than the number of columns
in the result set.
S1010 Function sequence error. Either hstmt is not in an executed state, or there is
an SQL statement already executing on hstmt.
01004 One or more columns was truncated. If string data, data is truncated on the
right. If numeric data, the fractional part is truncated. The condition causes
a return of SUCCESS_WITH_INFO.
07006 Data could not be converted into the type specified by fCType in the
SQLBindCol call.
24000 No results are pending on hstmt.
40001 The next row of results from an SQL SELECT with the NOWAIT keyword
was not fetched because a lock conflict was encountered. The application
may choose to sleep and retry the SQLFetch a few times before giving up.
SQLFetch SQLSTATE Values
SQLFetch 8-67
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLFreeConnect
SQLFreeConnect releases a connection handle and frees all resources associated with
it.
Syntax
RETCODE SQLFreeConnect (hdbc)
Input Variable
The following table describes the input variable.
Description
You must use SQLDisconnect to disconnect the connection handle before you release
the connection environment with SQLFreeConnect, otherwise an error is returned.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLFreeConnect SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLFreeConnect 8-69
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLFreeEnv
SQLFreeEnv frees the environment handle and releases memory associated with it.
Syntax
RETCODE SQLFreeEnv (henv)
Input Variable
The following table describes the input variable.
Description
You must use SQLFreeEnv to release all environment handles attached to the ODBC
environment before you release the environment with SQLFreeConnect; otherwise
an error is returned.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLFreeEnv SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
S1010 Function sequence error. The environment has at least one allocated hdbc.
SQLFreeEnv SQLSTATE Values
SQLFreeEnv 8-71
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLFreeMem
SQLFreeMem releases memory allocated by UCI software, thus preventing
problems caused by calling different memory managers from the same application.
Syntax
RETCODE SQLFreeMem ( memptr )
Input Variable
The following table describes the input variable.
Description
The SQLBindMvCol function allocates memory as necessary to hold multivalued
data, and returns a pointer to the allocated memory. The user is responsible for freeing
the allocated memory, using the SQLFreeMem function.
SQLFreeStmt
SQLFreeStmt allows you to perform one of several operations on a statement handle,
depending on the option chosen.
Syntax
RETCODE SQLFreeStmt (hstmt, fOption)
Input Variables
The following table describes the input variables.
Description
Use this function at the end of processing to free resources used by an SQL statement,
to reset parameter marker bindings, or unbind column variables.
If your program uses the same SQL statement environment to execute different SQL
statements, you can use SQLFreeStmt either with the SQL_CLOSE option, which
should be sufficient in most cases, or with the SQL_DROP option. In the latter case,
you need to call SQLAllocStmt to reallocate a new SQL statement environment.
It is good practice to issue a call to 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.
SQLFreeStmt 8-73
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
fOption 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 (or
SQLSetParam) calls. No more data can be fetched from this
hstmt until the SQL statement associated with the hstmt is
executed again with SQLExecute. Note that reexecuting an
hstmt which has not been prepared is not permitted. This option
is functionally equivalent to SQLCancel.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLFreeStmt SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLGetData
SQLGetData retrieves data that exceeds the buffer space allocated for it. It also
retrieves data from columns in the result set that were not bound.
Syntax
RETCODE SQLGetData (hstmt, icol, fCType, rgbValue, cbValueMax, pcbValue)
Input Variables
The following table describes the input variables.
UWORD icol Column number in the result set, numbered left to right
starting at 1.
SWORD fCType C data type of the result for the column. See C Data Types
Supported in Chapter 7, “Data Types,” for a complete list.
SDWORD cbValueMax If nonzero, this value specifies, for binary and character
data, the maximum size allocated for the rgbValue buffer.
SQLGetData Input Variables
SQLGetData 8-75
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Output Variables
The following table describes the output variables.
PTR rgbValue Address of the buffer into which this call reads the data.
A value of 0 causes an error return from the function.
Description
This function is used in either of two circumstances:
To get data from a column that returns a data truncation error because the
application’s buffer is too small to contain all of the column data.
To get data from a column not bound by SQLBindCol. (You cannot use
SQLGetData on columns that have been bound using SQLBindMvCol
because fetching such columns always allocates enough memory
automatically.)
Note: When retrieving data that does not fit into a buffer, SQLGetData retrieves the
remaining data. It does not retrieve from the beginning of the text.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_NO_DATA_FOUND
SQLSTATE Values
The following table describes the SQLGetData SQLSTATE values.
SQLSTAT
E Description
IM979 The column was previously bound using SQLBindMvCol. Using the
single-valued SQLGetData function is therefore illegal.
S1000 General error for which no specific SQLSTATE code has been defined.
S1002 Either icol is 0 or exceeds the number of columns in the result set.
01004 Not all data for the column could be retrieved in this operation.
07006 Data could not be converted into the type specified by fCType in the
SQLGetData call.
24000 No results are pending on hstmt.
SQLGetData SQLSTATE Values
SQLGetData 8-77
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Example
The following pseudo-code shows how an application might deal with a situation
where the original buffer allocated for the data was too small:
SDWORD cbValueMax = 512, pcbValue = 0;
buffer = malloc (cbValueMax);
SQLBindCol (hstmt, 1, SQL_C_STRING, buffer, cbValueMax,
&pcbValue);
if (SQLFetch ( ) == 01004)
{
SQLGetFunctions
SQLGetFunctions returns information regarding whether a driver supports certain
functions.
Syntax
RETCODE SQLGetFunctions (hdbc, fFunction, pfExists)
Input Variables
The following table describes the input variables.
Output Variable
The following table describes the output variable.
Description
This function is implemented wholly within UCI and is for tools vendors who want
to use general code against UCI to verify that certain functions are available before
deciding how to implement something.
SQLGetFunctions 8-79
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
fFunction Values
The following fFunction values are recognized and are defined in the UCI.h include
file:
SQL_API_SQLALLOCCONNECT
SQL_API_SQLALLOCENV
SQL_API_SQLALLOCSTMT
SQL_API_SQLBINDCOL
SQL_API_SQLCANCEL
SQL_API_SQLCOLATTRIBUTES
SQL_API_SQLCONNECT
SQL_API_SQLDESCRIBECOL
SQL_API_SQLERROR
SQL_API_SQLEXECDIRECT
SQL_API_SQLEXECUTE
SQL_API_SQLFETCH
SQL_API_SQLFREECONNECT
SQL_API_SQLFREEENV
SQL_API_SQLFREESTMT
SQL_API_SQLGETCURSORNAME
SQL_API_SQLNUMRESULTCOLS
SQL_API_SQLPREPARE
SQL_API_SQLROWCOUNT
SQL_API_SQLSETCURSORNAME
SQL_API_SQLSETPARAM
SQL_API_SQLTRANSACT
Level 1 Functions
SQL_API_SQLCOLUMNS
SQL_API_SQLDRIVERCONNECT
SQL_API_SQLGETCONNECTIONOPTION
SQL_API_SQLGETDATA
SQL_API_SQLGETFUNCTIONS
SQL_API_SQLGETINFO
SQL_API_SQLGETSTMTOPTION
SQL_API_SQLGETTYPEINFO
SQL_API_SQLPARAMDATA
SQL_API_SQLSETCONNECTIONOPTION
SQL_API_SQLSETSTMTOPTION
SQL_API_SQLSPECIALCOLUMNS
SQL_API_SQLSTATISTICS
SQL_API_SQLTABLES
Level 2 Functions
SQL_API_SQLBROWSECONNECT
SQL_API_SQLCOLUMNPRIVILEGES
SQL_API_SQLDATASOURCES
SQL_API_SQLDESCRIBEPARAM
SQL_API_SQLEXTENDEDFETCH
SQL_API_SQLFOREIGNKEYS
SQL_API_SQLMORERESULTS
SQL_API_SQLNATIVESQL
SQL_API_SQLNUMPARAMS
SQL_API_SQLPARAMOPTIONS
SQL_API_SQLPRIMARYKEYS
SQL_API_SQLPROCEDURECOLUMNS
SQL_API_SQLPROCEDURES
SQL_API_SQLSETPOS
SQL_API_SQLSETSCROLLOPTIONS
SQL_API_SQLTABLEPRIVILEGES
SQLGetFunctions 8-81
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLGetFunctions SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLGetInfo
SQLGetInfo returns general information about the driver and the capabilities of the
database release.
Syntax
RETCODE SQLGetInfo (hdbc, fInfoType, rgbInfoValue, cbInfoValueMax,
pcbInfoValue)
Input Variables
The following table describes the input variables.
Output Variables
The following table describes the output variables.
SQLGetInfo 8-83
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Description
This function supports all of the possible requests for information defined in the
ODBC 2.0 specification. The #defines for fInfoType are contained in the UCI.h
include file.
fInfoType Values
The following table lists the valid values for fInfoType and documents the results
returned by the database.
SQLGetInfo 8-85
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Supported SQL
SQLGetInfo 8-87
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQL Limits
Conversion Information
SQLGetInfo 8-89
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Value
The following table describes the SQLGetInfo SQLSTATE value.
SQLSTAT
E Description
S1C00 Driver is not capable of handling any fInfoType not supported by this
function.
SQLGetInfo SQLSTATE Value
SQLGetStmtTimeOut
SQLGetStmtTimeOut gets the wait time before terminating an attempt to execute a
command and generating an error.
Syntax
SQLGetStmtTimeOut (hstmt, stmt_timeout)
Input Variables
The following table describes the input variable.
Output Variables
The following table describes the output variable.
SQLGetInfo 8-91
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLNumParams
SQLNumParams returns the number of parameters in an SQL statement.
Syntax
RETCODE SQLNumParams (hstmt, pcpar)
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
hstmt contains no parameters, pcpar is set to 0.
Return Values
SQL_SUCCESS
SQL_INVALID_HANDLE
SQL_ERROR
SQLSTATE Values
The following table describes the SQLNumParams SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLNumParams 8-93
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLNumResultCols
SQLNumResultCols returns the number of columns in a result set.
Syntax
RETCODE SQLNumResultCols (hstmt, pccol)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
SWORD * pccol Pointer to the number of columns in the result set returned
by hstmt (or 0 if hstmt did not return a result set).
SQLNumResultCols Output Variable
Description
Use this function after preparing or executing an SQL statement or procedure call to
find the number of columns in the result set returned. An application can use this
function to test whether a submitted SQL statement was a SELECT statement or a
procedure call that produced a result set. If the prepared or executed statement was
not a SELECT statement and therefore did not return a result set, pccol is set to 0.
Because the process of preparing a DDL statement also executes it, it is not possible
to prepare and test a DDL statement before it is executed.
You can also use this function when the type of SQL statement is unknown or when
the number of columns to be bound to application variables is unknown, for example,
when an application is processing SQL statements entered ad hoc by users.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLNumResultCols SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLNumResultCols 8-95
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLParamOptions
SQLParamOptions lets applications specify multiple values for each of the
parameters assigned by SQLBindParameter.
Syntax
RETCODE SQLParamOptions (hstmt, crow, pirow)
Input Variables
The following table describes the input variables.
UDWORD FAR * pirow Pointer to storage for the current row number.
As each row of parameter values is processed,
pirow is set to the number of that row. No row
number is returned if pirow is empty.
SQLParamOptions Input Variables
Return Values
SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_ERROR
SQL_INVALID_HANDLE
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
sets of values for the set of parameters associated with an INSERT statement, then
execute the INSERT statement once to perform the twenty insertions.
INSERT
UPDATE
DELETE
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.
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.
SDWORD crow; /* number of rows SQLParamOption will do */
SDWORD pirow; /* storage for SQLParamOptions reply, rows done
*/
SQLParamOptions 8-97
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
int pkint[20];
status = SQLAllocEnv(&henv);
status = SQLAllocConnect(henv, &hdbc);
status = SQLSetConnectOption(hdbc, (UWORD)SQL_OS_UID, 0, OsUid);
status = SQLSetConnectOption(hdbc, (UWORD)SQL_OS_PWD, 0, OsPwd);
status = SQLConnect(hdbc, szDSN, strlen(szDSN),
szSchema,strlen(szSchema));
status = SQLAllocStmt(hdbc, &hstmt);
crow = 20;
status = SQLParamOptions(hstmt, crow, &pirow);
status = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0, p1, 0, 0);
p2[index - 1] = itoa(index);
}
status = SQLExecute(hstmt);
printf("%d paramater marker sets were processed\n", pirow);
SQLPrepare
SQLPrepare passes an SQL statement or procedure call to the data source to prepare
it for execution at the server.
Syntax
RETCODE SQLPrepare (hstmt, szSqlStr, cbSqlStr)
Input Variables
The following table describes the input variables.
Description
Use this function to deliver an SQL statement or procedure call to the data source
where it can be prepared for execution. The application subsequently uses SQLEx-
ecute to execute the prepared SQL statement or procedure. However, for DDL
statements (CREATE TABLE, DROP TABLE, GRANT, REVOKE, etc.), you need
only prepare the statement. You do not need to explicitly issue SQLExecute because
SQLPrepare handles the execution.
SQLPrepare 8-99
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Use SQLPrepare with SQLExecute when you are issuing SQL statements or calling
a procedure repeatedly. For example, if you are inserting or updating multiple rows
in a table, you can supply the values for a row to a prepared INSERT or UPDATE
statement and issue SQLExecute each time you change the values of the variables
bound to 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 the SQLBindParameter call;
otherwise SQLExecute returns an error.
You cannot prepare a DDL statement while a transaction is active. You must first
either commit or roll back the active transaction; otherwise SQLSTATE S1000 is
returned.
Parameter Description
argument Any valid keyword, literal, or other token you can use in a
database command line.
call Parameters
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLPrepare 8-101
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSTATE Values
The following table describes the SQLPrepare SQLSTATE values.
SQLSTAT
E Description
S0001 Table or view already exists. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code argument
of the SQLError call.
S0002 Table or view not found. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code argument
of the SQLError call.
S0021 Column already exists. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code argument
of the SQLError call.
S0022 Column not found. Several database error codes can produce this
SQLSTATE. The specific reason is returned in the native error code argument
of the SQLError call.
S1000 General error for which no specific SQLSTATE code has been defined.
21S01 Insert value list does not match the value list.
21S02 Number of columns in derived table does not match the column list.
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 happen for a variety of reasons. The
native error code returned by the SQLError call indicates the specific
database error that occurred.
SQLPrepare SQLSTATE Values
SQLRowCount
SQLRowCount returns the number of rows affected by an INSERT, UPDATE, or
DELETE statement.
Syntax
RETCODE SQLRowCount (hstmt, pcrow)
Input Variable
The following table describes the input variable.
Output Variable
The following table describes the output variable.
SDWORD * pcrow Pointer to the location into which the row count is
stored. If the count cannot be determined, this location
is set to 0.
SQLRowCount Output Variable
Description
The value of pcrow returned after executing a stored procedure may not be accurate.
It is accurate for a single INSERT, UPDATE, or DELETE statement. 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.
SQLRowCount 8-103
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLRowCount SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLSetConnectOption
SQLSetConnectOption lets an application control the way a particular connection
operates.
Syntax
RETCODE SQLSetConnectOption (hdbc, fOption, vParam, szParam)
Input Variables
The following table describes the input variables.
SQLSetConnectOption 8-105
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQL_TXN_READ_UNCOMMITTED (isolation
level 1)
SQL_TXN_READ_COMMITTED (isolation level 2)
SQL_TXN_REPEATABLE_READ (isolation level 3)
SQL_TXN_SERIALIZABLE (isolation level 4)
SQLSetConnectOption 8-107
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQL_UVNLS_MAP A value that defines the server NLS map for the
connection. The server must be able to locate the
map table, and the map table must be installed in
the server’s NLS shared memory segment.
szParam is the name of the map table.
szParam Values (Continued)
Description
Once SQLSetConnectOption sets an option for a connection, that option remains set
until it is specifically reset or the connection is released using an SQLFreeConnect
statement.
As of Release 9.4.1, if you are connecting to a server running with NLS enabled, you
can use the SQLSetConnectOption call to specify the NLS map table
(SQL_UVNLS_MAP) and NLS locale information (SQL_UVNLS_LOCALE). You
can change these settings after opening the connection, provided a transaction is not
active.
Note: Certain combinations of clients and servers may not transfer data predictably
because of a mismatch in character mapping, locale settings, or both. See
Connecting to a UniVerse Server with NLS Enabled in Chapter 4, “Developing UCI
Applications” for more information.
If the DSN is not the local host, the client passes the requested user name, password,
and schema/account name through to the server. The server verifies the user
name/password combination with the operating system and if that is valid, verifies
that the requested schema is a valid schema or valid account on the server. Finally,
the NLS map and locale settings, if set, are sent to the server. If any of these steps
fails, an error is returned, indicating that the server rejected the connection request.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSetConnectOption SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been defined.
SQLSetConnectOption SQLSTATE Values
SQLSetConnectOption 8-109
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSTATE Description
SQLSetStmtTimeOut
SQLSetStmtTimeOut sets the wait time before terminating an attempt to execute a
command and generating an error.
Syntax
SQLSetStmtTimeOut (hstmt, stmt_timeout)
Input Variables
The following table describes the input variables.
SDWORD stmt_timeout The time, in seconds, to wait for the command to execute.
SQLSetParam Input Variables
SQLSetConnectOption 8-111
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLSetParam
SQLSetParam is provided for compatibility with ODBC 1.0 and the UniVerse
BASIC SQL Client Interface. It specifies where values for parameter markers can be
found when an SQLExecute or SQLExecDirect call is issued. SQLSetParam is a
front end to SQLBindParameter, which is the preferred interface to this functionality.
Syntax
RETCODE SQLSetParam (hstmt, ipar, fCType, fSqlType, cbColDef, ibScale,
rgbValue, pcbValue)
Input Variables
The following table describes the input variables.
SWORD fCType The C data type of the parameter. Must be one of the
supported C data types as described in Chapter 7, “Data
Types.”
Description
This call is mapped to the SQLBindParameter call as follows:
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLSetParam SQLSTATE values.
SQLSTATE Description
S1000 General error for which no specific SQLSTATE code has been specified.
S1093 ipar was less than 1 or greater than the number of parameters in the SQL
statement.
07006 The fCType data type cannot be converted to the fSqlType data type.
SQLSetParam SQLSTATE Values
SQLSetParam 8-113
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLTables
SQLTables returns a result set listing the tables matching the search patterns.
Syntax
RETCODE SQLTables (hstmt, szTableQualifier, cbTableQualifier, szTableOwner,
cbTableOwner, szTableName, cbTableName, szTableType, cbTableType)
Input Variables
The following table describes the input variables.
UCHAR * szTableType Table type search pattern, which can be one of the
following: BASE TABLE, VIEW,
ASSOCIATION, or TABLE.
Description
This function returns hstmt as a standard result set of five columns containing the
qualifiers (schemas), owners, names, types, and remarks for all tables found by the
search. The search criteria arguments can contain a literal or 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. szTableOwner cannot specify a LIKE pattern. You can access the result set
with SQLFetch. These five columns have the following descriptors:
Note: The table owner is the user ID of the person who created the table. SQLTables
accepts the table owner search pattern as a character string, but that character string
must equate to an integer value and must not contain wildcards.
SQLTables 8-115
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
Table Qualifer Table Owner Table Name Table Type Return is...
SQL_1NF_MODE_OFF The default. Virtual 1NF tables are returned from the catalog
with their TableType defined as ASSOCIATION to distinguish
them from the underlying physical NF2 tables. Refer to
Handling Multivalued Columns in Chapter 4, “Developing
UCI Applications” for an explanation of NF2 mode.
SQL_1NF_MODE_ON Virtual 1NF tables are returned from the catalog with their
TableType defined as TABLE. This enables 1NF users to treat
them as discrete tables and to aid interfaces that look for the
text TABLE to identify base table objects in the result set of
SQLTables. Virtual 1NF tables are distinguishable from base
tables because their TableType is TABLE, while the TableType
for base tables is BASE TABLE. Refer to Handling Multi-
valued Columns in Chapter 4, “Developing UCI Applications”
for an explanation of 1NF mode.
Impact of 1NF Mode
The SQL statement used in both modes when all four search patterns are empty is:
SELECT TABLE_SCHEMA, OWNER, TABLE_NAME, TABLE_TYPE, REMARKS
FROM UV_TABLES
ORDER BY 4, 1, 2, 3;
If one or more search patterns are specified, the appropriate SQL WHERE clause is
inserted.
The ability to obtain information about tables does not imply that you have any privi-
leges on those tables.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQL_SUCCESS_WITH_INFO
SQLSTATE Values
The following table describes the SQLTables 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.
42000 Syntax error or access violation. This can happen for a variety of reasons.
The native error code returned by the SQLError call indicates the specific
database error that occurred.
SQLTables SQLSTATE Values
SQLTables 8-117
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLTransact
SQLTransact starts a manual-commit mode transaction, or requests a COMMIT or
ROLLBACK for all SQL statements associated with a connection or all connections
associated with an environment.
Syntax
RETCODE SQLTransact (henv, hdbc, fType)
Input Variables
The following tables describes the input variables.
Description
This function provides the UCI programmer with the same transaction functions as
exist in BASIC with the BEGIN TRANSACTION, COMMIT, and ROLLBACK
statements.
You can begin a transaction at a particular transaction isolation level by adding the
isolation level to the fType parameter. This is equivalent to the BASIC syntax BEGIN
TRANSACTION ISOLATION LEVEL level. The valid fType parameter values are
as follows:
SQLTransact 8-119
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
If any action fails, SQL_ERROR is returned, and the user can determine which
connections failed by calling SQLError for each hdbc in turn.
Return Values
SQL_SUCCESS
SQL_ERROR
SQL_INVALID_HANDLE
SQLSTATE Values
The following table describes the SQLTransact SQLSTATE values.
SQLSTAT
E Description
S1000 General error for which no specific SQLSTATE code has been defined.
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
SQLTransact 8-121
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Ch8
2/21/08
SQLUseCfgFile
SQLUseCfgFile lets an application specify which UCI configuration file to use.
Syntax
RETCODE SQLUseCfgFile (henv, option, pathname)
Input Variables
The following table describes the input variables.
Description
SQLUseCfgFile specifies the full pathname of the UCI configuration file. You can
use SQLUseCfgFile to change the default name of the UCI configuration file from
uci.config to whatever you like. SQLUseCfgFile verifies the existence of the
specified configuration file.
If you do not use SQLUseCfgFile to specify a configuration file, UCI locates the
uci.config file by searching the following directories in order:
Return Values
SQL_SUCCESS
SQL_ERROR
SQLSTATE Values
When SQLUseCfgFile returns SQL_ERROR, you can call SQLError to get the
associated SQLSTATE value. Common SQLSTATE values returned are:
SQLSTATE Description
SQLUseCfgFile 8-123
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Appendix
Error Codes
A
This appendix lists the SQLSTATE error codes and the SQL and ODBC
error conditions they represent. General ODBC errors produce the
default SQLSTATE error code of S1000.
Beta Beta 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 Beta Beta
SQLSTATE Message
IM975 Output parameter markers are valid only with procedure calls
IM976 UCI connections to databases other than UniVerse and UniData are not
allowed
IM983 Nested transactions to databases other than UniVerse and UniData are not
allowed
A-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLSTATE Message
IM989 Illegal expiration date format for the SQL Client Extender
IM992 Exceeded licensed number of users for the SQL Client Extender
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
SQLSTATE Message
A-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
950599 UniVerse/SQL: “name” is not a base table; not valid for REFERENCES.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
950043 UniVerse/SQL: type1 and type2 types are incompatible in this operation.
950121 UniVerse/SQL: Column “columnname” data type does not match insert
value.
UniVerse SQL Error Codes (Continued)
A-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
950122 UniVerse/SQL: Column “columnname” data type does not match update
value.
950568 UniVerse/SQL: Can’t update existing rows with NULL default for NOT
NULL column.
040065 FATAL: The locks necessary for database operations at the current isolation
level (level) are not held by this process.
950251 UniVerse/SQL: NOWAIT, Can’t lock record, conflict with another user.
950259 UniVerse/SQL: NOWAIT, Can’t lock file, conflict with another user.
950260 UniVerse/SQL: NOWAIT, Can’t lock record, conflict with user "user".
UniVerse SQL Error Codes (Continued)
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
950261 UniVerse/SQL: NOWAIT, Can’t lock file, conflict with user "user".
950305 UniVerse/SQL: username does not have rwx permission for name, cannot
create schema.
950306 UniVerse/SQL: username does not have rw permission for name, cannot
create schema.
950352 UniVerse/SQL: You must be DBA to create a schema for another user.
UniVerse SQL Error Codes (Continued)
A-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
950362 UniVerse/SQL: Command aborted, you may not revoke your own
privileges.
950405 UniVerse/SQL: You do not have sufficient privileges to GRANT on this file.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Code Message
A-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
81002 On an SQLConnect call, this indicates that the service name specified by
the data source was not present on the server, the unirpcservices file was not
found, or the service name was not found in the unirpcservices file.
81004 Error occurred while trying to store an argument in the transmission packet.
81005 The client and server are running incompatible versions of the UniRPC
protocol.
81010 A mismatch in the number of arguments passed between the client and
server was detected.
81011 Unknown host. The host name or IP address specified in the data source is
not valid for the network.
81012 The UniRPC daemon (unirpcd) could not start the uvserver executable.
#ifdef _WIN32
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
#include <windows.h>
#include <direct.h>
#include <stdio.h>
#include <conio.h>
#else
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <termio.h>
#endif
#include "UCI.h"
#ifndef _WIN32
/* begin external function declarations */
SCHAR *itoa();
/* end external function declarations */
#endif
/*
* The ERRCHECK macro shows a way to simplify the checking of
errors
* returned by UCI functions and obtaining error state and message
from
* SQLError. This macro cannot be used to check SQLAllocEnv
*/
/*
* The print_carray function is provided to show how to use the
C_ARRAY
* structure returned by SQLBindMvCol; it mimics uniVerse VERTICAL
listing
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
*/
while (ui--)
{
printf("%-11s.", (udptr == pca->Data) ? szLabel : szBlank);
if (udptr->fIndicator == SQL_NULL_DATA)
{
printf(" <null>\n");
}
else if (udptr->fIndicator == SQL_BAD_DATA)
{
printf(" <data could not be converted>\n");
}
else switch (pca->fCType)
{
case SQL_C_CHAR:
case SQL_C_STRING:
printf(" %s\n", udptr->uValue.string.text);
break;
case SQL_C_DOUBLE:
printf(" %f\n", udptr->uValue.dbl);
break;
case SQL_C_FLOAT:
printf(" %f\n", (double)udptr->uValue.flt);
break;
case SQL_C_TINYINT:
case SQL_C_STINYINT:
printf(" %d\n", (int)udptr->uValue.sbyte);
break;
case SQL_C_UTINYINT:
printf(" %d\n", (int)udptr->uValue.ubyte);
break;
case SQL_C_SHORT:
case SQL_C_SSHORT:
printf(" %d\n", (int)udptr->uValue.sword);
break;
case SQL_C_USHORT:
printf(" %d\n", (int)udptr->uValue.uword);
break;
case SQL_C_LONG:
case SQL_C_SLONG:
printf(" %d\n", (int)udptr->uValue.sdword);
break;
case SQL_C_ULONG:
printf(" %d\n", (int)udptr->uValue.udword);
break;
case SQL_C_DATE:
B-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppB
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
printf(" %02d-%02d-%04d\n",
(int)udptr->uValue.date.day,
(int)udptr->uValue.date.month,
(int)udptr->uValue.date.year);
break;
case SQL_C_TIME:
printf(" %02d:%02d:%02d\n",
(int)udptr->uValue.time.hour,
(int)udptr->uValue.time.minute,
(int)udptr->uValue.time.second);
break;
}
udptr++;
}
return;
}
/*
* This routine frees a C_ARRAY structure allocated by
SQLBindMvCol
*/
free(pca);
*ppca = 0;
return;
}
/*
* This routine will get the password without echoing it
*/
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
char *getpasswd(passwd)
char *passwd;
{
#ifndef _WIN32
struct termio tio, tiosave;
int status;
char *ptr;
for(;;)
{
c = getch();
if ( c == '\r') break;
*ptr++ = (char)c;
}
*ptr = 0;
return( passwd );
#endif
}
main(argc, argv)
intargc;
char *argv[];
{
HENV henv; /* the environment handle
*/
HDBC hdbc; /* a connection handle
*/
HSTMT hstmt; /* a statement handle
*/
RETCODE ret; /* the return code from UCI functions
*/
SDWORD i; /* local loop counter
*/
SDWORD fNativeError; /* uniVerse error code from SQLError
*/
SWORD cbErrorMsg; /* length of buffer for error text
*/
B-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppB
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
/*----------------------------------------------------------------
*/
/* Connect to the uniVerse server
*/
/*----------------------------------------------------------------
*/
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
");
szDSN[0] = 0;
gets(szDSN);
if ( szDSN[0] == 0)
{
printf("\nEmpty data source. Exiting\n");
exit(EXIT_FAILURE);
}
if (SQL_ERROR == SQLAllocEnv(&henv))
{
printf("\nDied in SQLAllocEnv\n");
exit(EXIT_FAILURE);
}
/*
Connect to the UniVerse server(szDSN)
using the specified destination (szSchema)
*/
printf("Enter valid server User Name: ");
OsUid[0] = 0;
gets(OsUid);
if ( OsUid[0] == 0)
{
printf("\nEmpty user name. Exiting\n");
exit(EXIT_FAILURE);
}
B-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppB
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ERRCHECK("SQLSetCOnnectOption")
/*----------------------------------------------------------------
*/
/* First example
*/
/*----------------------------------------------------------------
*/
/*
(1) Bind all columns using SQLBindMvCol even if they are
single-valued because it's simpler
(2) Obtain the column headings for the report
*/
for (i = 0; i < 5; i++)
{
ret = SQLBindMvCol(hstmt, i+1, (i == 1) ? SQL_C_STRING :
SQL_C_USHORT,
&pCarray[i]);
ERRCHECK("SQLBindMvCol");
while (1)
{
ret = SQLFetch(hstmt);
ERRCHECK("SQLFetch");
if (ret == SQL_NO_DATA_FOUND)
{
break;
}
else if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
{
printf("\n");
for (i = 0; i < 5; i++)
{
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
/*----------------------------------------------------------------
*/
/* Second example
*/
/*----------------------------------------------------------------
*/
B-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\AppB
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
{
printf("\nUPDATE statement failed\n");
exit(EXIT_FAILURE);
}
printf("\nUniVerse/SQL: %d record updated.", crow);
/* the next statement only uses one parameter so clear out old
ones */
ret = SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
ERRCHECK("SQLFreeStmt");
/*----------------------------------------------------------------
*/
/* Clean up section
*/
/*----------------------------------------------------------------
*/
ret = SQLDisconnect(hdbc);
ERRCHECK("SQLDisconnect");
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ret = SQLFreeConnect(hdbc);
ERRCHECK("SQLFreeConnect");
ret = SQLFreeEnv(henv);
ERRCHECK("SQLFreeEnv");
B-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Glossary
2/21/08 Using SQL in UniVerse
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta Beta Beta
Glossary
1NF mode A database mode in which all nonfirst-normal-form (NF2) tables are treated as first-
normal-form (1NF) tables. In 1NF mode, only singlevalued data is available to the
application. Associations of multivalued columns are unnested into singlevalued
tables.
API Application programming interface. A set of function calls that provide services to
application programs.
application A user program that issues function calls to submit SQL statements and retrieve
program 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.
autocommit mode A mode of database operation in which each SQL statement is treated as a separate
transaction.
binding The process of associating an attribute with an SQL statement, such as associating
parameters or columns with a statement.
coercion The conversion of data returned by the server. Using UCI, an application program can
coerce data from a UniVerse table or file into application program variables.
connection A pointer to memory allocated and initialized with the data necessary to describe and
handle maintain a connection between the SQL client application and the data source. Each
connection can have multiple statements associated with it.
cursor A virtual pointer to the set of results produced by a query. A cursor points to the
“current row” of the result set, one row of data at a time, and advances one row at a
time.
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta Beta Beta
DDL Data definition language. A subset of SQL statements used for creating, altering, and
dropping schemas, tables, views, and indexes. These statements include ALTER
TABLE, CREATE SCHEMA, CREATE TABLE, CREATE VIEW, CREATE
INDEX, CREATE TRIGGER, DROP SCHEMA, DROP TABLE, DROP VIEW,
DROP INDEX, DROP TRIGGER, GRANT, and REVOKE.
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.
DSN Data source name. The name associated with a specific data source entry in the
uvodbc.config file.
data source A source of data, or database engine, represented by the specifications supplied in the
data source entry in the uvodbc.config file. These specifications include the DBMS
type, network, name of the service, and host platform.
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 information concerning the state of the
handle application’s data connections, including the valid connection handles.
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.
multivalued A column that can contain more than one value for each row in a table.
column
Glossary 2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Glossary
2/21/08 Using SQL in UniVerse
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta Beta Beta
NF2 mode A database mode in which all nonfirst-normal-form (NF2) tables are treated as such.
This is the standard mode for UniVerse.
null value A special value representing an unknown value. This is not the same as 0 (zero), a
blank, or an empty string.
ODBC Open Database Connectivity. An interface that defines a library of function calls that
permit a client application program to connect to a data source, execute SQL
statements against that source, and retrieve results. It also provides a standard set of
error codes, a way to connect to the data source, and a standard set of data types. The
ODBC specifications from Microsoft for SQL-based database interoperability cover
both the application programming interface and SQL grammar. UCI is modelled on
this standard but is not ODBC compliant.
precision The maximum number of digits defined for an SQL data type.
prepared SQL An SQL statement that has been processed with the SQLPrepare function. Once
statement prepared, an SQL statement can be executed repeatedly.
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
language 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.
scale The maximum number of digits allowed to the right of the decimal point.
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta Beta Beta
single-valued A column that can contain only one value for each row in a table.
column
statement handle A pointer to memory allocated and initialized to hold the context of an SQL
statement. A statement handle is always associated with a connection handle.
UCI Uni Call Interface. A C application programming interface (API) that lets application
programmers write client application programs that use SQL function calls to access
data in UniVerse databases.
uci.config file The client UCI configuration file, which defines data sources to which an application
can connect in terms of DBMS, network, service, host, and optional extended
parameters.
udserver process A UniData server process that handles requests from the client. For each client
connection to the server there is one udserver process.
UniDK Uni Development Kit. The UniDK comprises UCI, UniObjects, UniObjects for Java,
and InterCall.
UniRPC Remote procedure call. UCI uses a library of calls developed by IBM to implement
remote procedure calls. The UniRPC lets a server system execute a function
(procedure) provided by a client application program. The client application program
passes arguments to the server as well as an identifier specifying the procedure to be
executed on the server. The server executes the procedure, using the arguments
passed to it, and then returns the results to the client.
unirpc service On Windows ervers, the service that waits for a client’s request to connect. When it
receives a request, unirpc creates the connection to the server.
unirpcd daemon On UNIX servers, the daemon that waits for a client’s request to connect. When it
receives a request, unirpcd creates the connection to the server.
unirpcservices The UniRPC services file on the server, used by the UniRPC daemon or service to
file locate the UniVerse server executable image (uvserver).
UniVerse BASIC Also known as BCI (BASIC Client Interface). A UniVerse BASIC application
SQL Client programming interface that makes UniVerse a client in a client/server environment.
Interface Using BCI, UniVerse clients can access both UniVerse and non-UniVerse data
sources.
uvserver process A UniVerse server process that handles requests from the client. For each client
connection to the server there is one uvserver process.
Glossary 4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\uci\Glossary
2/21/08 Using SQL in UniVerse
Beta BetaBeta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaBeta Beta Beta Beta Beta Beta
Win32 API The primitive Windows operating system interface for Windows platforms. In this
architecture the fundamental size of integers and pointers is 32 bits.
Index
Index
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
and SQL data types 7-9 compiling BASIC procedures 6-4 data model 4-5
supported 7-3 configuration see also 1NF mode, NF2 mode
unsupported 7-5 client system 3-5 setting 8-112
call arguments 8-6 client system for NLS server 3- data source
call interfaces 12 to 3-13 entry 4-5
advantages 1-4 server system 3-3 name (DSN) 8-45
SQL 1-3 server system running NLS 3-4 data sources
call level interface (CLI), see API configuration file, see UCI connecting to a data source 8-45
CALL statement 5-3, 5-5, 6-2 configuration file definition Gl-2
nested 6-15 configuration parameters 3-5 DATA statements 6-3, 6-15
calling procedures 5-2 to 5-7 not relevant to UCI 3-8 data truncation errors, retrieving
cancelling relevant to UCI 3-5 truncated data 8-82
current query 8-79 configuring UCI 3-2 to 3-13 data types 7-2 to 7-14
processing of current SQL connecting to a database 4-5, 8-45 and C data types 7-9
statement 8-32 connection handles 4-5 and SQL data types 7-9
cascading changes to normalized NF2 allocating memory for 8-11 databases, connecting to 4-5
tables 4-27 closing connection associated DATA_TYPE column attribute 8-42
CASE configuration parameter 3-5 with 8-56 DATE data type 7-9
cataloging BASIC procedures 6-4 freeing resources associated with 8- date values returned as C structures 7-6
CHARACTER data type 7-9 73 DATEFETCH configuration
CHAR_MAX_LENGTH column releasing 8-73 parameter 3-8
attribute 8-42 connections DATEFORM configuration
client interface, see UCI closing 8-56 parameter 3-8
client system, configuring 3-5 controlling 8-111 DATEPREC configuration
closing definition Gl-1 parameter 3-8
connections 8-56 retrieving errors associated with 8-59 DBLPREC configuration parameter 3-
open cursors 8-79 controlling how connections operate 8- 8
@HSTMT variable 6-16 111 DBMSTYPE configuration
coercion count, affected row 5-5, 5-6, 6-5, 6-6, parameter 3-5
data types 7-10 6-7 DDL statements
parameters 7-11 CREATE INDEX statements 4-15 definition Gl-2
columns CREATE SCHEMA statements 4-15 and dynamic normalization 4-27
binding 8-17 CREATE TABLE statements 4-15 and nested transactions 4-21
fetching results from 8-69 CREATE VIEW statements 4-15 processing 4-15
getting descriptions 8-41, 8-52 cursors 4-16 debugging procedures 6-16
getting detailed attributes of 8-34 closing open 8-79 DECIMAL data type 7-9
getting number of columns in result definition Gl-2 default isolation levels 4-5, 4-22
set 8-100 C_ARRAY data type 7-5 setting 8-113
unbound, retrieving data from 4-17, structure 7-8 DELETE statements 4-15
8-82 and dynamic normalization 4-27
values 8-69 getting number of rows affected
COLUMN_NAME column D by 8-109
attribute 8-42 and nested transactions 4-21
data definition language statements, see
commands in procedures 6-6
DDL statements
as procedures 6-2 DESCB4EXEC configuration
data definition statements in
calling as procedures 5-3 parameter 3-5
procedures 6-6
COMMIT statement, requesting for all developing UCI applications 4-2 to 4-
data manipulation language statements,
SQL statements 8-125 27
see DML statements
COMO command 6-3 requirements 1-8
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
diagnostics area, see SQL diagnostics EODCODE configuration exchanging data 8-4
area parameter 3-8 initializing 8-4
disconnecting connections 8-56 error memory management 8-5
display size 7-12, 7-13, 7-14 information, getting 8-58 processing errors 8-5
DML statements return codes 4-18, 8-8, A-1 to ?? reference 8-4 to 8-130
definition Gl-2 UniRPC A-12
and dynamic normalization 4-26 error codes A-2 to ??
processing 4-15 UniVerse 5-7 G
documentation conventions 1-ix errors 6-7
GRANT statements 4-15
DOUBLE PRECISION data type 7-9 checking for 4-17
drivers messages 5-7
getting general information about 8- SQL 6-12
89 SQLSTATE 4-18
H
getting information about functions executing procedures 5-2 to 5-7 halting processing associated with
supported 8-85 executing SQL statements 4-11 statement handle 8-79
DROP INDEX statements 4-15 directly 4-11 handles 8-5
DROP SCHEMA statements 4-15 preparable 8-62 connection 4-5
DROP TABLE statements 4-15 prepared 4-13, 8-66 definition Gl-1
DROP VIEW statements 4-15 definition Gl-2
DSN (data source name) 4-6, 8-45 environment 4-4
definition Gl-2 F definition Gl-2
DSPSIZE configuration parameter 3-5 statement 4-9
fetching
dynamic normalization 4-26 definition Gl-4
column results 8-18
and DDL statements 4-27 HDBC argument 8-6
rows of data 4-17, 8-69
definition Gl-2 HENV argument 8-6
specifying where to return results 8-
and DELETE statements 4-27 HOST configuration parameter 3-5
17
and DML statements 4-26 HSTMT argument 8-6
files
and 1NF mode 4-24 Hungarian naming conventions 1-xi,
configuration, see UCI configuration
and primary keys 4-25 8-8
file
and referential integrity 4-27
installation 2-3
Make.UCI 2-3
UCI configuration 2-4, 4-5
I
E ucimsg.text 2-3, 2-4 implicit referential integrity 4-27
embedded SQL ucisample.c 2-3, 2-4 initializing application program 4-4
definition Gl-2 UCI.a 2-3 input in procedures 6-3, 6-15
versus an SQL call interface 1-3 uci.config 3-2 to 3-13, Gl-4 INPUT statements 6-15
empty strings 7-7 UCI.h 2-3, 2-4, 4-4 input variables 8-6
as null values 7-7 unirpcservices 2-8, 3-3 INSERT statements 4-15
and SQLBindMvCol 8-23 @TMP 6-9 getting number of rows affected
environment, retrieving errors first-normal-form mode, see 1NF mode by 8-109
associated with 8-59 first-normal-form tables 4-24 and nested transactions 4-21
environment handles FLOAT data type 7-9 and 1NF mode 4-24
allocating memory for 4-4, 8-13 FLOATPREC configuration in procedures 6-6
definition Gl-2 parameter 3-8 installing UCI 2-3
freeing 8-75 function calls 8-4 files 2-3
releasing memory associated with 8- arguments used in 8-6 INTEGER data type 7-9
75 functions internal/external formats and C data
environment variables, PATH 2-10 disconnecting 8-5 types 7-6
Index 3
February 21, 2008 3:40 pm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 5
February 21, 2008 3:40 pm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
SQL_SUCCESS_WITH_INFO return maintaining the UCI configuration configuration parameters not relevant
value 8-8 file 2-10 to 3-8
SQL_TIME data type 7-9 configuration parameters relevant
SQL_TXN_ISOLATION option 8- to 3-5
113 T configuring 3-2 to 3-13
SQL_UNBIND option 8-79 configuring client for NLS server 3-
tables
SQL_UVNLS_LC_ALL option 8-114 12 to 3-13
first normal form 4-24
SQL_UVNLS_LC_COLLATE configuring NLS server 3-4
getting description of tables found by
option 8-114 data types 7-3 to 7-14
search pattern 8-120
SQL_UVNLS_LC_CTYPE option 8- developing applications 4-2 to 4-27
nonfirst-normal-form 4-23
114 function call reference 8-4 to 8-130
TABLE_NAME table attribute 8-42,
SQL_UVNLS_LC_MONETARY language support 1-5
8-121
option 8-114 overview 1-2 to 1-8
TABLE_OWNER table attribute 8-42,
SQL_UVNLS_LC_NUMERIC requirements for developing
8-121
option 8-114 applications 1-8
TABLE_SCHEMA table attribute 8-
SQL_UVNLS_LC_TIME option 8- requirements for running
42, 8-121
114 applications 1-8
TABLE_TYPE table attribute 8-121
SQL_UVNLS_LOCALE option 8-114 as an SQL call interface 1-3
tags in function syntax 8-8
SQL_UVNLS_MAP option 8-114 SQL data types supported 7-9
TCP/IP network 1-6
SQL_VARCHAR data type 7-9 UNIX installation 2-3
terminating statements 4-18
SSPPORTNUMBER configuration files 2-3
TIME data type 7-9
parameter 3-8 UCI configuration file 2-4, 4-5
time values returned as C structures 7-
statement handles editing 3-8
6
definition Gl-4 maintaining on client 2-10
transaction isolation levels 4-22
halting all processing associated ucimsg.text file 2-3, 2-4
default 4-22
with 8-79 ucisample.c file 2-3, 2-4, 4-3
transaction modes 4-10
releasing 8-78 source code B-1 to B-11
autocommit 4-10
releasing resources associated UCI.a file 2-3
manual-commit 4-10
with 8-78 uci.config file 3-2 to 3-13
transactions 4-20 to 4-22
statements changing parameters in 3-10
nested 4-20
retrieving associated errors 8-59 definition Gl-4
nesting levels 4-20
terminating 4-18 UCI.h file 2-3, 2-4, 4-4
TXBEHAVIOR configuration
status variables 8-8 UCI_DATUM data type 7-5
parameter 3-7
stored sentences UDWORD argument 8-6
TXCOMMIT configuration
as procedures 6-2 unbinding
parameter 3-7
calling as procedures 5-3 bound columns 4-18
TXROLL configuration parameter 3-7
string math 7-6 parameters 4-18
TXSTART configuration parameter 3-
SUBROUTINE statement 6-4 unbound columns, retrieving data
7
subroutines 5-3 from 8-82
TYPENAME configuration
as procedures 6-2 UniData data types, see data types
parameter 3-7
subtransactions UniData internal/external formats, see
TYPE_NAME column attribute 8-42
see also nested transactions internal/external formats
isolation levels 4-22 UniData release, getting information
SWORD argument 8-6 about 8-89
syntax
U UniDK (Uni Development Kit) 2-4
prefixes in 8-8 UCHAR argument 8-6 definition Gl-4
tags in 8-8 UCI UniRPC
system administration compliance with ODBC 2.0 administering 2-10
administering the UniRPC 2-10 standard 1-7 daemon 2-10, 3-3
Index 7
February 21, 2008 3:40 pm
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @