121
KB_SQL ODBC Driver Guide A guide to the KB_SQL ODBC Driver

KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide A guide to the KB_SQL ODBC Driver

Page 2: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have
Page 3: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

iii

Table Of Contents

KB_SQL ODBC Driver ...................................................................................................... 1

Understanding ODBC ......................................................................................................... 3

Driver Installation and Setup .............................................................................................. 5

Server and Network Configuration ..................................................................................... 9

Server Info ...................................................................................................................... 9

Network Configuration ................................................................................................. 10

TroubleShooting ........................................................................................................... 14

Starting the Server......................................................................................................... 16

Starting the Server..................................................................................................... 16

Stopping the Server ....................................................................................................... 17

Stopping the Server ................................................................................................... 17

Simulating ODBC with QUICK^SQL .............................................................................. 19

Managing ODBC Data Sources ........................................................................................ 21

Data Sources ................................................................................................................. 21

Tracing ODBC Calls ..................................................................................................... 22

Tracing_on_the_Client ............................................................................................. 22

Tracing_on_the_Server ............................................................................................. 24

Connection Pooling ....................................................................................................... 26

Windows Applications ...................................................................................................... 29

Programming Considerations............................................................................................ 31

ODBC API Calls ........................................................................................................... 34

M Programming ............................................................................................................ 37

Page 4: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

iv

ActiveX Data Objects (ADO) ....................................................................................... 66

Appendixes ....................................................................................................................... 67

A - Escape Sequences ................................................................................................... 67

B - Connection Options ................................................................................................ 72

C - Error Messages........................................................................................................ 75

D - Info Types ............................................................................................................... 80

E - Data Types .............................................................................................................. 87

Index ................................................................................................................................. 89

Page 5: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

1

KB_SQL ODBC Driver

KB_SQL ODBC Driver

The KB_SQL ODBC Driver allows you to connect your M database to a world of

applications. This document describes the ODBC solution in the context of the KB_SQL

Server product provided by Knowledge Based Systems, Inc.

For more information about ODBC, please see the Microsoft documentation available at

www.microsoft.com/data

For questions about KB_SQL, please see the documentation available at

www.knowledgebasedsys.com

To report a problem, or to get technical support, licensed users should have their database

administrator contact KBS technical support at [email protected].

Page 6: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have
Page 7: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

3

Understanding ODBC

What is ODBC?

ODBC (Open Database Connectivity) is a standard interface developed by Microsoft for

accessing data from different kinds of SQL database management systems. See

www.microsoft.com/data for additional information.

What does this mean to the M Community?

• This means that you can use many of the Windows applications already on your

desktop to get to your M data.

• With the KB_SQL Server together with the KB_SQL ODBC Driver, you can now

use the Microsoft Office programs including Excel, Word, and Access or any

ODBC-compliant Windows application to access your M data.

• You have many more choices for data access and reporting of your M application

data.

How does it work?

The KB_SQL ODBC Architecture consists of six main components:

• your Windows application programs

• the ODBC Driver Manager

• the KB_SQL ODBC Driver

• networking software (TCP/IP)

• the KB_SQL Server Interface

• the KB_SQL Engine and relational data dictionary

The KB_SQL ODBC Architecture

• Resident on your workstation, the client side, you need your Windows

applications, the ODBC Driver Manager, the KB_SQL ODBC Driver, and the

networking software.

• Your Windows applications can be any ODBC-compliant Windows application.

They can be commercial off-the-shelf products like Microsoft’s Excel and Visual

Basic or custom applications.

• Microsoft provides The ODBC Driver Manager component. Its primary function

is to load the driver. If it is not resident on your system at the time you install the

KB_SQL ODBC Driver, the setup program, on your installation disk, will install

it for you.

• The KB_SQL ODBC Driver enables any ODBC-compliant Windows application

to access data from your KB_SQL RDBMS. The driver must be accessible to

each workstation that wants to use Windows applications to access the KB_SQL

Server. You can install the driver on as many workstations as you like. Access to

Page 8: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

4

your M data is limited only by your KB_SQL license, which determines the

number of concurrent users.

• Networking software is necessary to communicate between the Driver and Server.

The KB_SQL ODBC Driver requires TCP/IP networking software.

• On your server, you need to install KB_SQL Server and you need to have your M

globals mapped as SQL tables into a SQL data dictionary. If you have any

previous version of KB_SQL, this has already been done.

• The KB_SQL Server Interface encapsulates the Server API and Network Library

M, and exposes the KB_SQL Engine to the client.

Benefits of KB_SQL ODBC

• You are free to select the application that is most appropriate for the task at hand.

At any point in time, you can choose to use either the EZQ or SQL Editors that

come packaged with KB_SQL, or you can select from many ODBC-compliant

Windows applications.

• You can continue to access your M data from a terminal or choose a workstation

that has access to a KB_SQL ODBC Driver.

• KB_SQL ODBC simplifies application development. You can write a single

application that can be used to extract data from many different databases,

permitting maximum interoperability and portability of the application.

• With KB_SQL ODBC, accessing M is like accessing any other RDBMS.

Actually, the fact that you may be accessing different types of databases

concurrently is transparent to you.

Page 9: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

5

Driver Installation and Setup

Before you begin

Before installing the KB_SQL ODBC Driver, there are a couple of items to note.

• Is the Server installed and configured?

• Do you know the Server configuration parameters for the Hostname (or IP

address), and listening port?

• Can you ping the Server using the Hostname (or IP address)?

• Do you have Administrator privileges?

Driver Installation

Step 1: Launch the KB_SQL ODBC Driver Installer.

Step 2: Accept the terms of the license agreement.

After accepting the terms, the installer will update your system with the KB_SQL ODBC

Driver and other ODBC Components.

Page 10: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

6

Create a

Default Data Source

The installer continues, allowing you to create a Data Source as part of the installation.

Step 4: Give the Data Source a name and description.

Step 5: Specify the Network parameters.

Page 11: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Driver Installation and Setup

7

Step 6: Specify a Code Page Translator

Step 7: Congratulations!

Page 12: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

8

Page 13: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

9

Server and Network Configuration

Server Info

ServerInfo

Prefix for stored query routines

Assign a name to the holding place for the last x number of queries run. For example, if

you enter XA, the Server API allocates routine names starting with XA1 up to the

maximum number of stored queries specified.

Maximum number of stored queries

Enter the number of queries that you want held in the stored queries buffer on the server.

The value you supply is a matter of storage space versus processor resources. Assigning a

large number requires more storage capacity but less processing time. Conversely,

assigning a smaller number requires less space to store queries, but causes more

processing by the SQL engine. Here’s why: As the Server API receives each SQL

command, it checks the stored queries buffer for the command’s corresponding M

routine. If it finds the M routine, it simply runs it. If it doesn’t, it has to use the SQL

engine to translate the command into one or more M routines. The M routine and

corresponding SQL command are then stored and assigned a routine name using the base

routine prefix. If you specify a large number, say 999, many commands can be processed

before having to reuse a stored query for another command. When the maximum number

Page 14: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

10

has been reached, KB_SQL reuses the oldest stored query to store the next query’s M

routine and corresponding SQL command. You may clear the stored queries buffer of all

routine names by invoking the RL^SQL tag.

Allow connections

Answer YES to accept connections to the server. Answer NO if you want to refuse

connections. Note that the server will not start if the system lock is set. (Refer to the

UTILITIES\LOCK STATUS option.)

If the server is running and you want to stop allowing connections, first invoke the

STOP^SQL0SVR function. Then set this prompt to NO.

Regardless of the setting of this prompt, the server can always be run in foreground—

useful for testing purposes when you don’t want the server to be started in background.

If the server is not running when you set this value to YES, you still have to start the

server. It is not automatically started. To start the server, see the instructions for starting

and stopping the KB_SQL Server later in this chapter.

Trace API calls

Answer YES if you want to track information about the dialog between the server and

clients. This creates a log that you can view by using the SQL Editor to run the

SQL_API_SERVER_TRACE query, or by using the tag VIEW^SQL0SVR.

Edit network configuration

Answer YES if you want to edit TCP/IP defaults or host information. The TCP/IP

Defaults window will appear. A discussion of this process begins on the next page.

Server initial execute

Enter the M code that will instantiate any variables that are required by your application

during the runtime execution of queries.

Server user initial execute

Enter the M code that will validate and/or establish the username (SQLUNAME) and

password (SQLUAUTH) variables referenced during the connection to the server.

Network Configuration

NetworkInfo

In general, the network information you are required to provide consists of the TCP/IP

host and port information. Depending on your M implementation type, you might be

required to provide alternate ports.

Page 15: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Server and Network Configuration

11

Timeout for read

commands

Enter the number of seconds after which a READ command

should timeout and check error status (default = No timeout)

Maximum length

of M string

Enter the maximum size of an M string value in this

implementation (default = 511).

Output buffer size Enter the output buffer size in bytes (default = 2048).

Input buffer size Enter the input buffer size in bytes (default = 2048).

Page 16: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

12

TCP/IP Host Definition

Host name Enter the TCP/IP hostname for the server.

IP address Enter the internet protocol address for the server. If your system uses

dynamic ip address allocation, enter the host name in this field.

Description Enter a brief description of this server.

Local host? Enter YES if you are describing the server on which KB_SQL is running.

Enter NO if you are documenting another server.

Page 17: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Server and Network Configuration

13

TCP/IP Port Definition

Port

number

The port number is expected to be in the range of 5000-65535.

Port

server?

Answer YES if this is the published port for connecting to this server.

Answer NO if this is an alternate port to be used internally.

Page 18: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

14

TroubleShooting

Network Troubleshooting

Troubleshooting network connections can be challenging due to complex configurations.

However, we've found that most of the errors related to KB_SQL have been incorrectly

configured servers. It is easy to check the configuration of your server using our built-in

testing tool, TEST^SQL0TCP.

In general, we try to include useful information in error message displays. As for

networking errors, we try to include the Windows Sockets (WinSock) error code as part

of the message. If you see 10061 - Connection Refused, you probably need to check that

your server is started. If you receive the error 10065 - No Route to Host, you might have

specified a host address incorrectly.

Using TEST^SQL0TCP

VMS Cluster Issues

Using TEST^SQL0TCP

There are low-level TCP/IP testing tools available through KBS technical support. If you

think you are having network trouble, please call us.

Starting with KB_SQL v3.6, we provide a simple utility to test the configuration of your

Server and Network. The TEST^SQL0TCP utility will attempt connections from your

Server back to itself, and keep trying connections until it fails.

For example:

>D TEST^SQL0TCP

KB_SQL Server Connect Test

Server Name or Address: 127.0.0.1//

Port Number : 6500//

UserName : DBA

PassWord :

Connecting to 127.0.0.1 (6500)

Error in connect: 0579: TCP/IP Timeout in Open

As the error message implies, the attempt to connect has timed out. The most likely cause

is that the server is not started.

>D START^SQL0SVR

>W $D(SQLERR)

0

This attempt to start the server is successful, as it does not return an error in the SQLERR

variable.

Now, try the connect test again.

>D TEST^SQL0TCP

KB_SQL Server Connect Test

Server Name or Address: 127.0.0.1//

Port Number : 6500//

UserName : DBA

PassWord :

Connecting to 127.0.0.1 (6500)

Connected to #1: |TCP|5~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Page 19: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Server and Network Configuration

15

Connected to #2: |TCP|6~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #3: |TCP|7~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #4: |TCP|8~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #5: |TCP|9~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #6: |TCP|10~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #7: |TCP|11~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Connected to #8: |TCP|12~127.0.0.1~6500 ...

Connecting to 127.0.0.1 (6500)

Error in connect:

[S1000] (139): [Knowledge Based Systems, Inc.][Server API][Version]SQLConnect:

Exceeded KB_SQL license limit

Disconnecting #8: |TCP|12~127.0.0.1~6500 ...

Disconnecting #7: |TCP|11~127.0.0.1~6500 ...

Disconnecting #6: |TCP|10~127.0.0.1~6500 ...

Disconnecting #5: |TCP|9~127.0.0.1~6500 ...

Disconnecting #4: |TCP|8~127.0.0.1~6500 ...

Disconnecting #3: |TCP|7~127.0.0.1~6500 ...

Disconnecting #2: |TCP|6~127.0.0.1~6500 ...

Disconnecting #1: |TCP|5~127.0.0.1~6500 ...

Notice that it gets 8 connections before it encounters an error. It shows that this attempt

to connect is rejected because it would exceed the current limit of your license. This is

the error that you want to get in this context. It ensures that everything is working. If you

get other errors, it is helpful to pass on the information to our technical support.

Currently, the most common problem with connecting is that the Server is not started. We

recommend adding START^SQL to your system startup logic.

The second most common problem is for those M types that require alternate ports (ISM,

DSM, and others), that not enough are configured. We always recommend configuring at

least as many ports as you have connections on your license. Configuring more doesn't

hurt either. VMS Cluster issues

On VMS clusters, it gets very tricky when starting an M process to “listen” for

connections.

The M database has a single definition of the local host.

One or more nodes can access the database.

Starting the “listener” from a node other than the one identified in the local host setting

can have confusing consequences.

One way of preventing this problem is to disable the auto startup feature using Site Edit.

Page 20: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

16

Another way is to add code to the Server StartUp Execute to test whether the current

node matches the local host definition. If it doesn't, then the Server should not be allowed

to start. Simply return an error in SQLERR.

Starting the Server

Starting the Server

There are several methods available for starting the KB_SQL Server. You may start it

either in the foreground for analysis and debugging purposes or in the background for a

multi-user production environment.

Foreground Options

Background Options

Foreground

You may run the KB_SQL Server in foreground during configuration until you are

satisfied that you are able to connect and process client requests. The following

foreground options are available:

1. Output to Screen

Command:

>D ^SQL0SVR

Description: This command is for general configuration, analysis and debugging.

Sample Output:

Waiting for client connection ...

KBSGetInfoShort("1010","23") = (0,"2")

KBSGetInfoShort("1010","24") = (0,"2")

SQLAllocStmt("1010") = (0,"2007")

SQLPrepare("2007","select * from employees") = (0,"1")

SQLNumResultCols("2007") = (0,"4")

SQLDescribeCol("2007","1") = (0,"EMP_SSN","12","11","0","0")

SQLDescribeCol("2007","2") = (0,"NAME","12","15","0","0")

SQLDescribeCol("2007","3") = (0,"SALARY","2","5","2","1")

SQLDescribeCol("2007","4") = (0,"MANAGER","12","11","0","1")

SQLExecute("2007") = (0)

KBSRowsetFrame("2007","1","20480") = (100,"48","102-44-

3545","JOHNSON","9","416-82-6316",...

SQLFreeStmt("2007","0") = (0)

SQLFreeStmt("2007","0") = (0)

SQLDisconnect("1010") = (0)

2. Output to File

Command:

>D FILE^SQL0SVR("[FILE NAME]")

Page 21: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Server and Network Configuration

17

Example:

>D FILE^SQL0SVR("c:\temp\svrtrace.log")

Description: This command is used to capture the output from a client/KB_SQL Server

interaction for analysis, debugging, or submittal to KBS Technical Support.

3. Output to Printer

Command:

>OPEN %DEV USE %DEV DO ^SQL0SVR CLOSE %DEV

Example:

>O 3 U 3 D ^SQL0SVR C 3

Description: This command is used to capture output from a client/KB_SQL Server

interaction for analysis, debugging, or submittal to KBSs Technical Support.

4. Without Error Trapping

Command:

DO NOTRAP^SQL0SVR

Description: This option turns off KB_SQL error trapping. When a hard M error is

encountered, the server will stop and the error will be displayed in the native format for

your M implementation

Note: The foreground server options are intended only for analysis or debugging

purposes. As it allows only a single connection, it is not appropriate for a multi-user

environment. Background

If you have answered Yes to Allow Connections? in Site Edit/Server Info and your

KB_SQL Server is properly configured, you may start the server simply by logging into

KB_SQL as a DBA or System Manager. You may also type:

>D START^SQL0SVR

at the M prompt. This command line option allows you to start KB_SQL Server during

the startup of your M system or other times without the requirement to log into KB_SQL.

If, for some reason, the Server fails to start, the variable SQLERR may be trapped and be

used to determine the reason for failure.

Stopping the Server

Stopping the Server

You may need to stop the KB_SQL Server for various reasons (shutting down M, system

maintenance, etc.) You may stop the KB_SQL Server with the following command:

D STOP^SQL0SVR

This command may be called from procedures such as Shutdown, etc.

Page 22: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

18

Note: It is important to understand that this command does not affect current connections

to the KB_SQL Server. It does, however, prevent any new connections from being

established. As some applications require multiple database connections for operation, it

is best to ensure that everyone is logged off before stopping the KB_SQL Server. You may

check current connection status by choosing Connections on the System Status menu.

Page 23: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

19

Simulating ODBC with QUICK^SQL

Using QUICK^SQL

The Quick SQL Editor (QUICK^SQL) is a KB_SQL query interface that lets you use

Windows Notepad to enter your SQL statements, save the statements as a text file, and

execute the file from the QUICK utility. Queries executed from this interface take the

same path as a query created from an ODBC application. Because of this you can use this

editor to simulate queries from ODBC applications. The Quick SQL Editor is also a

valuable tool for testing stored procedures and parameterized queries.

>D QUICK^SQL

Password:

Enter SQL Command

GO Execute command

STOP Exit

RESET Clear command

CALL procedure() Call stored procedure

@file Read commands from file

-->SELECT NAME, PROJECT FROM PROJECTS

-->GO

NAME PROJECT

GREEN PHARMACY

ROBERTS LABORATORY

ROBERTS MEDICAL RECORDS

GREEN ACCOUNTING

(4 rows)

Page 24: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have
Page 25: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

21

Managing ODBC Data Sources

Data Sources

Data Source Types

There are two types of data sources: machine data sources and file data sources. Although

both contain similar information about the source of the data, they differ in the way this

information is stored. Because of these differences, they are used in somewhat different

manners.

Data

source

Description

User

DSN

These are local to a computer, and can only be used by the current user. User

data sources are registered in the HKEY_CURRENT_USER registry subtree.

System

DSN

These are local to a computer, rather than dedicated to a user. The system, or

any user having privileges, can use a data source set up with a system data

source. System DSNs are registered in the HKEY_LOCAL_MACHINE

registry subtree.

File

DSN

These are file-based sources that can be shared between all users that have the

same drivers installed, and so have access to the database. These data sources

need not be dedicated to a user or local to a computer. File data sources do not

have a data source name, as user or system data sources do; they are identified

by a file name with a DSN extension.

User and system data sources are collectively known as machine data sources because

they are local to a computer.

Each of these data sources has a tab in the ODBC Administrator that is dedicated to that

type.

File DSN

File data sources are stored in a file and allow connection information to be used

repeatedly by a single user or shared among several users. When a File DSN is used, the

Driver Manager makes the connection to the data source using the information in a .dsn

file. This file can be manipulated like any other file. A File DSN does not have a data

source name, as does a machine data source, and is not registered to any one user or

machine.

A File DSN streamlines the connection process, because the .dsn file contains the

connection string that would otherwise have to be built for a call to the

SQLDriverConnect function. Another advantage of the .dsn file is that it can be copied

to any machine, so that identical data sources can be used by many machines as long as

they have the appropriate driver installed. A File DSN can also be shared by applications.

Page 26: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

22

A shareable File DSN can be placed on a network and used simultaneously by multiple

applications.

A file DSN can also be unshareable. An unshareable .dsn file resides on a single machine

and points to a machine data source. Unshareable File data sources exist mainly to allow

the easy conversion of machine data sources to File DSN so that an application can be

designed to work solely with File DSNs. When the Driver Manager is sent the

information in an unshareable File DSN, it connects as necessary to the machine data

source that the .dsn file points to.

Example

Here is an example of a File DSN for a KB_SQL connection. Note that the file is

typically stored in the default path provided by Microsoft, but the file can be stored

anywhere including on a networked drive.

C:\Program Files\Common Files\ODBC\Data Sources\KBSQL.DSN

[ODBC]

DRIVER=KB_SQL ODBC 32-bit Driver

UID=DBA

SERVER=KB_SQL

MaximumString=220

CommunicationBuffer=20

Network=C:\WINNT\System32\kbnet32.dll

Setup=C:\WINNT\System32\kbset32.dll

TCP_PORT=6500

HOST=192.9.90.36

Tracing ODBC Calls

Tracing API Calls

One of the best ways to understand what is going on when an application uses an ODBC

connection to a remote data source is to trace the conversations. There are several

conversations going on. The client-side-trace refers to the tracing of the conversation

between the application and the ODBC Driver Manager. The server-side-trace refers to

the tracing of the conversation between the KB_SQL ODBC Driver and the KB_SQL

Server.

In general, the server-side trace is the most useful to KBS support and is also the easiest

to interpret.

The client-side trace is a secondary source of information. It can be challenging to

interpret -- let us help you.

Tracing_on_the_Client

Tracing on the Client

The ODBC Driver Manager has a trace facility that allows the sequence of function calls

made by an ODBC application to be recorded and transcribed into a log file. Tracing is

Page 27: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Managing ODBC Data Sources

23

performed by a trace DLL that captures calls between the application and the Driver

Manager, and the Driver Manager and the driver. This method of tracing replaces the

tracing performed by the ODBC 2.x Driver Manager and the tracing performed in ODBC

2.x by ODBC Spy.

Enabling tracing

Certain situations call for examination of the conversational exchange between the

application and the driver manager. This can be accomplished using the tracing option

provided by Microsoft.

Sample trace output

The trace file can be large and its contents are not intuitive. However, these details are

invaluable to KBS technical support representatives when trying to diagnose application

Page 28: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

24

behaviors.

Tracing_on_the_Server

Tracing on the Server

In developing your own custom Windows applications for use with your KB_SQL

database, you may find it necessary from time to time to view the interaction between

your application and the KB_SQL Server. All communication between ODBC-compliant

applications and KB_SQL occurs in sequences of function calls. These function calls

may be recorded and reported on for both informative and debugging purposes.

The following sections will describe the enabling of the API Trace feature and the

viewing of the output of an API Trace session.

Enabling the API Trace Feature

Viewing the API Trace

Interpreting the API Trace

Enabling the API Trace Feature

1. Sign on to KB_SQL as DBA or System Administrator.

2. Choose SYSTEM STATUS.

Page 29: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Managing ODBC Data Sources

25

3. Choose SERVER INFO.

4. Choose TRACE OPTIONS.

5. Select ENABLE TRACING.

Caution: The API Trace feature is intended for informative and debugging purposes only.

It is not intended to be run in a production environment. If it is necessary to use the trace,

we recommend turning it on right before you use it and turning it off immediately

afterwards.

Viewing the API Trace

1. Sign on to KB_SQL.

2. Choose SYSTEM STATUS.

3. Choose SERVER INFO.

4. Choose TRACE OPTIONS.

5. Select VIEW TRACE.

Page 30: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

26

Interpreting the API Trace

Upon running the SQL_API_SERVER_TRACE query, you will see a screen describing

the connection information for the most recent KB_SQL Server connection. Following

this information is the sequence of function calls from the client application to the

KB_SQL Server, ordered from earliest to last.

There are a number of sources you may use in helping you to determine the functionality

behind each of these function calls:

• The online query SQL_API_LIST. This query lists all ODBC API functions

supported by KB_SQL with a brief description of each.

• See ServerAPI functions for an overview of the KB_SQL ODBC Architecture as

well as a detailed description of all currently supported function calls.

• The Microsoft ODBC 2.0 Programmer’s Reference and SDK Guide. This is the

definitive work on the ODBC specification. KBS recommends this book to

anyone involved in developing and deploying ODBC-compliant applications.

Connection Pooling

Connection pooling

Connection pooling enables an application to use a connection from a pool of established

connections. If a connection has already been created and placed in a pool, an application

can use that connection without performing the entire connection process. Re-using

Page 31: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Managing ODBC Data Sources

27

connections from the pool can increase performance since applications can save the

overhead involved in making a connection. This is especially significant for middle-tier

applications that connect over a network or in a situation where the application repeatedly

connects and disconnects (e.g. Internet applications).

Enabling Connection Pooling

Connection pooling can be used by an ODBC application if the application calls

SQLSetEnvAttr with the SQL_ATTR_CONNECTION_POOLING attribute. In order to

enable connection pooling with KB_SQL’s ODBC driver, it will be necessary to enable

the feature and set the timeout value via the ODBC administrator. This timeout value

determines the period of time which an inactive connection is removed from the pool.

Page 32: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have
Page 33: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

29

Windows Applications

Overview of Windows Applications

Using Windows Applications with KB_SQL is just as it is for using Windows

applications with any other SQL Data Source.

See the documentation for the specific Windows application for more information about

working with SQL Data Sources.

Microsoft Access

Connecting

Connecting from Microsoft Access to your M system is easy using the KB_SQL ODBC

Driver. The connection will be attempted based on a decision made within Access,

typically during the file linking process. You are able to use any of the connection types

and you will be expected to log in with your KB_SQL username and password.

Save password

During the connection process, you will have the option of saving your username and

password with the Access database information. This would allow you to reopen the

database and reconnect to the server without having to reenter your username and

password information. Note also that this capability can be disabled by correctly

configuring the MsysConf table on the server. Contact KB Systems technical support for

more information.

Should I import or link a table?

Microsoft Access provides two choices for using data from an external source:

• Import the M data into a new Microsoft Access table in the current database.

• Leave the data in the M database and use it in its current format without importing

it -- this is called linking.

If you know you will use your data only in Microsoft Access, you should import it.

Microsoft Access generally works faster with its own tables, and if you need to, you can

modify the imported table to meet your needs just like any other table created in

Microsoft Access. One of the key considerations here is the volume of data and the

security issues related to removing a copy from the server. These issues should be

considered with your application vendor or information systems department

representative.

If the data you want to use is also being updated by a program other than Microsoft

Access, you should link it. Using this approach, the current methods of updating,

managing, and sharing the data can remain in place, and you can use Microsoft Access to

work with the data as well. For example, you can create queries, forms, and reports that

use the external data, combine external data with the data in Microsoft Access tables, and

even view and edit the external data while others are using it in the original program.

Recordsets: Dynasets and Snapshots

Page 34: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

30

Microsoft Access uses the JET (Joint Exchange Technology) Engine to manage database

interactions. The JET Engine is a powerful query processor with many features, including

the intelligence to perform distributed queries across multiple data sources. The results of

queries run through JET are stored in record sets. These record sets can be of two types:

Dynasets or Snapshots. For the most part, you will probably want snapshots as these are

designed purely for retrieval and reporting purposes. If you are doing updates, dynasets

will allow you to update rows on the remote data source.

Data types

Microsoft Access has its own set of data types. These types are mapped onto the ODBC

types which are themselves mapped on to the data types supported on the data source.

This can lead to confusion. The documentation for Microsoft Access is your best guide to

understanding why the data appears different in an Access database than it does when

you look at the same data on the server.

Microsoft Query

Connecting

Connecting from Microsoft Query to your M system is easy using the KB_SQL ODBC

Driver. As of Microsoft Office97, MSQuery was biased towards the use of file DSNs.

This limitation is removed with Microsoft Office97 Service Pack #2. You are able to use

any of the connection types and you will be expected to log in with your KB_SQL

username and password.

GetExternalData

The option to use MSQuery from Excel and Word is dependent on your installation. The

MSQuery component is not installed by default. If it is not available to you, check with

your system administrator.

Return Data to Excel

Assuming you have the option installed for getting external data, the obvious next step is

to return the data to Excel. The rules for saving the data, query, and password information

are all controlled by the Microsoft applications. Please check with the application

documentation if you have questions about how data is returned.

Data types

Microsoft Query has its own set of data types. These types are mapped onto the ODBC

types which are also mapped to the data types supported on the data source. This can lead

to confusion. The documentation for Microsoft Query, Excel, or Word is your best guide

to understanding why the data appears different in a Microsoft Office application than it

does when you look at the same data on the server.

Page 35: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

31

Programming Considerations

Architecture

Accessing the KB_SQL Engine from Windows

The KB_SQL Client API can be accessed as a dynamic link library (DLL) from

Windows via C or Visual Basic. A Windows programming paradigm, the DLL allows

one copy of a set of functions to be accessed by multiple applications. In Visual Basic,

the Server API is accessed directly through the KB_SQL ODBC Driver. The ODBC

Driver Manager is not involved. Again, TCP/IP provides your connection to the Server

API.

Expectations:

• Experience with Windows programming, DLLs, Windows applications, and

gateways

Statement Execution

The KB_SQL API supports two methods of statement execution: the direct method

(using the SQLExecDirect function) and the prepare/execute method (using the

SQLPrepare and SQLExecute functions). When an SQL statement is prepared it is sent to

the server, parsed, and optimized. This is the ideal method for statements that are

executed repeatedly, each time with different parameter values.

An application should prepare a statement for execution if any of the following are true:

• The application will repeatedly execute the statement.

• The application needs information about the result set before executing the

statement.

An application can execute a statement directly if both are true:

• The application will execute the statement only once.

• The application does not need information about the result set before executing

the statement

Parameters

An application can send parameters at statement execution time by calling the following

functions:

SQLBindParameter specifies the SQL data type of the parameters and reserves storage

location for each parameter.

SQLPutData sends data value for the parameter to the driver.

Page 36: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

32

Using data-at-execution parameters is useful for applications handling long data.

See also Parameter_Markers

Parameter Markers

Parameter markers in a prepared SQL statement are placeholders for parameter values

that are supplied by an application. Parameter markers are delimited by question marks.

Using parameter markers in an SQL statement lets you execute the statement repeatedly

with different values. This is a more efficient alternative to coding literal values in an

application, and changing the application each time the parameters change.

To use parameter markers, the application must first call the SQLBindParameter function

to bind a storage area to a parameter marker. Then the application must place the

parameter’s value in the storage location. Examples of using parameter markers are found

in the Stored Procedures section of this chapter.

See also Parameters

Stored Procedures

The KB_SQL Server API supports the use of stored procedures as a collection of

precompiled SQL statements residing on the server. An application can call a procedure

in place of an SQL statement. Stored procedures help to increase performance and

consistency when performing repetitive tasks because they are compiled the first time

they are executed. When executed again, subsequent run time is much shorter than for the

equivalent set of stand-alone statements.

Stored procedures simplify application development because you can repeatedly change

them without modifying and compiling the application.

Stored procedures can be created for permanent or temporary use.

Temporary Stored Procedures

KB_SQL creates a stored procedure for every set of SQL statements that are submitted

from client applications. These procedures are available for use by all server queries for

as long as the procedure is in the buffer of stored queries on the server.

The query text is stored under a name like @SERVER_nnn, where nnn represents the

number of the query relative to the number of stored queries allowed.

IMPORTANT: DBA users can copy the definition of a server query into a new

query, but server queries should not be modified in any way.

Permanent Stored Procedures

KB_SQL can make any stored procedure permanent so that it will always be available

regardless of the size of the stored query buffer. This type of procedure is desirable for

use within custom applications. It allows the application to be developed independently

of the server-side SQL statements. Only the calling parameters and result set must stay

constant. Otherwise, the stored procedure can be modified as needed without affecting

the client application.

Steps to create a permanent stored procedure

1. Create a query that returns a result set in the ODBC format.

SET CLIENT=ODBC

Page 37: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

33

This parameter is automatically inserted into SQL statement buffers sent from client

applications. Setting STORED_PROCEDURE implicitly sets the CLIENT type.

2. Indicate that the procedure is permanent.

SET STORED_PROCEDURE=YES

This makes the query take on the characteristics of a stored procedure until you remove

the setting. This query will appear in the result set for the SQLProcedures function.

3. Give names to input parameters (optional).

SET PARAMETERS='name,city,state'

You can choose to specify names for parameter markers in any query.

This acts as documentation, and is accessible in the result of the SQLProcedureColumns

function. Note that setting PARAMETERS implicitly sets the CLIENT type and

STORED_PROCEDURE indicators.

Running a stored procedure

Replace the SQL statements in your application with the ODBC escape clause syntax for

calling a stored procedure.

Syntax

{call procedure-name[(parameter[,parameter...])]}

Example

Replace:

Select Name, Position, Salary, Comments

From Employees

Where EmpDept = ?

With:

{call DeptEmps(?)}

The ‘?’ represents a parameter marker, in this case used to receive the department

identifier.

Rules

• Users must have SELECT privileges on the stored procedure query.

• The stored procedure query must be compiled in order to show in

SQLProcedures, SQLProcedureColumns, or to be executed.

• The server will require that the number of parameters in the reference must match

the number in the procedure definition.

• Parameter values can be specified as all literals, or all parameter markers, but not

a mix. For example:

Legal

{call xyzProc(?,?)}

{call xyzProc('abc','123')

Illegal

{call xyzProc(?)} -- 2 parameters required

{call xyzProc('abc',?)} -- Cannot mix types

Page 38: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

34

• If the parameters or the result set changes, you would have to respecify your

application. Otherwise, changes can be made to the logic on the server side by

editing and recompiling the query.

Testing stored procedures

You may test stored procedures by using the sample routine SQLJ13. This program will

let you enter the ODBC syntax for calling the procedure.

Example

>{call xyzProc(?,?)}

>go

Use the Execute SQL option in MSQuery to invoke a stored procedure. Note that this

interface does not have a mechanism for collecting input parameters, so you must supply

the values as string

literals.

Example

{call xyzProc('abc','123')}

ODBC API Calls

Functions

KB_SQL API Function Summary

Below are the KB_SQL API functions, grouped by type of task, including a brief

description of the purpose of each function. For more information about the syntax and

semantics of each function, consult the alphabetical reference section of this chapter.

Task Function Name Purpose

Connecting to a data

source

SQLAllocEnv Obtains an environment handle.

An environment handle can be used for

one or more connections.

SQLAllocConnect Obtains a connection handle. A

connection handle can be used for one

or more statements.

SQLConnect Connects to a specific driver by data

source name, user ID, and password.

SQLDriverConnect* Connects to a specific driver by

connection string or invokes driver

display connection dialog boxes.

Obtaining information

about a driver and data

source

SQLGetInfo Returns information about a specific

driver and data source.

SQLGetTypeInfo Returns information about supported

Page 39: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

35

data types.

SQLGetFunctions Returns supported driver functions.

Setting and retrieving

driver options

SQLSetConnectOption Sets a connection option.

SQLGetConnectOption Returns the value of a connection

option.

SQLSetStmtOption Sets a statement option.

SQLGetStmtOption Returns the value of a statement

option.

Preparing SQL

requests

KBSStatement Inserts partial SQL statements.

SQLAllocStmt Allocates a statement handle.

SQLPrepare Prepares an SQL statement for later execution.

SQLBindParameter Assigns storage for a parameter in an SQL

statement.

SQLGetCursorName Returns the cursor name associated with a

statement handle.

SQLSetCursorName Specifies a cursor name.

Submitting

requests

SQLDescribeParam Returns the description of a parameter marker

associated with a prepared SQL statement.

SQLExecute Executes a prepared statement.

SQLExecDirect Executes a statement.

SQLNativeSql Returns the SQL command text as translated by

the server.

SQLNumParams Returns the number of parameters in an SQL

statement.

SQLParamData* Used in conjunction with SQLPutData to supply

parameter data at execution time.

SQLPutData Send part or all of a data value for a parameter.

Retrieving Results

and information about

results

SQLRowCount Returns the number of rows affected by

an insert, update, or delete request.

SQLNumResultCols Returns the number of columns in the

result set.

SQLDescribeCol Describes a column in the result set.

SQLColAttributes Describes attributes of a column in the

result set.

SQLBindCol Assigns storage for a result column and

Page 40: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

36

specifies the data type.

SQLFetch Returns a result row.

SQLGetData Returns a specific column value from a

statement cursor.

Retrieving Results

and information about

results

(continued)

SQLError Returns additional error or status

information.

Obtaining information

about the data

source’s system tables

(catalog functions)

SQLColumnPrivileges Returns a list of columns and associated

privileges for the specified table.

SQLColumns Returns a list of column names in

specified tables.

SQLForeignKeys Returns information about the foreign

keys for a table.

SQLPrimaryKeys Returns the list of column name(s) that

comprise the primary key for a table.

SQLProcedures Returns the list of procedure names stored

in a specific data source.

SQLSpecialColumns Returns information about the optimal set

of columns that uniquely identifies a row

in a specified table, or the columns that

are automatically updated when any value

in the row is updated by a transaction.

SQLStatistics Returns statistics about a single table and

the list of indexes associated with the

table.

SQLTablePrivileges Returns a list of tables and the privileges

associated with each table.

SQLTables Returns the list of table names stored in a

specific data source.

Terminating a

statement

SQLFreeStmt Ends statement processing and closes any

associated cursors, discarding pending

results, and optionally, frees all resources

associated with the statement handle.

SQLCancel Cancels an SQL statement.

SQLTransact Commits or rolls back a transaction.

Terminating a

connection

SQLDisconnect Closes the connection.

SQLFreeConnect Releases the connection handle.

SQLFreeEnv Releases the environment handle.

Page 41: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

37

For information on using the ODBC API functions from other programming languages,

see the Microsoft ODBC Software Development Kit and Programmer's Reference.

M Programming

Overview_M_Programming

KB_SQL API Function Reference

The following pages describe each KB_ SQL API function in alphabetic order. Each

function is defined as an M programming language function.

Descriptions may include some or all of the following items:

• Arguments

• Returns

• Syntax

• Examples

• Notes

• Options

• Result set

• Related functions

Add SQL access to your M routines.

KB_SQL provides SQL access to M data. You can choose to leverage this power for

reporting, data browsing, updating, or any combination. With the KB_SQL API

functions, you can encapsulate your SQL references in your M programs. This

combination allows you to leverage your M programming skills with a well-defined,

controlled interface to the data using SQL.

A Word about Variable Names.

Variable names shown in the following functions are used for illustrative purposes only.

KB_SQL reserves the letters “SQL” for use as the first three letters of our variable

names. We suggest you use variable name conventions suitable to your operation.

KBSStatement

Inserts part of an SQL command into the SQL input buffer.

Arguments

Statement handle [SQLHSTMT]

SQL command [SQLTEXT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$KS^SQLOS(SQLHSTMT,SQLTEXT)

Example

Page 42: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

38

S SQLCODE=$$KS^SQLOS(SQLHSTMT, SQLTEXT)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function can be used to insert partial SQL commands to the SQL server. Its

purpose is to support SQLPrepare.

• Splits should occur on a space or punctuation character. A special subroutine,

SPLIT^SQLK4, may be invoked to automate this process

For example, suppose X contains a long line (375 characters), thus exceeding the default

limitation of 255 bytes M imposes on strings.

X SELECT COL1, COL2, COL3, COL4, COL5, COL6,

COL7, COL8, COL9, COL10, COL11, COL12, COL13, COL14,

COL15, COL16, COL17, COL18, COL19, COL20, COL21, COL22,

COL23, COL24, COL25, COL26, COL27, COL28, COL29, COL30,

COL31, COL32, COL33, COL34, COL35, COL36, COL37, COL38,

COL39, COL40 FROM TABLE WHERE COL1 = 100 AND (COL2 = 200)

ORDER BY COL3

You can invoke the SPLIT^SQLK4 subroutine to decompose the line into smaller

segments. It attempts to split first on a space boundary, followed by one of several

punctuation characters.

>D SPLIT^SQLK4

X(0) 7

X(1) SELECT COL1, COL2, COL3, COL4, COL5, COL6, COL7,

X(2) COL8, COL9, COL10, COL11, COL12, COL13, COL14,

X(3) COL15, COL16, COL17, COL18, COL19, COL20, COL21,

X(4) COL22, COL23, COL24, COL25, COL26, COL27, COL28,

X(5) COL29, COL30, COL31, COL32, COL33, COL34, COL35,

X(6) COL36, COL37, COL38, COL39, COL40 FROM TABLE WHERE

X(7) COL1 = 100 AND (COL2 = 200) ORDER BY COL3

Now, you simply call KBSStatement for each entry in X(n).

When using this function, you must still invoke the SQLPrepare function. Typically,

this invocation occurs in the last segment of the SQL command text.

For example, assume X is very long. Below you see a sequence of typical statements

from the subroutine’s point of entry through the call to SQLPrepare.

>D SPLIT^SQLK4

>S N=X(0)

Note: X(0) contains the count of elements.

>F I=1:1:N-1 DO

> . SQLCODE=$$KS^SQLOS(SQLHSTMT,X(I)) I SQLCODE'=0 G Error

>S SQLCODE=$$P^SQLOS(SQLHSTMT,X(N))

Note: If you perform your own split logic, make sure you adhere to all of the rules

observed by the SPLIT^SQLKI subroutine.

SQLAllocConnect

Page 43: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

39

Allocates a connection handle.

Arguments

Environment handle [SQLHENV]

Returns

Return code [SQLCODE]

Connection handle [SQLHDBC]

Syntax

SQLCODE=$$AC^SQLOS(SQLHENV,.SQLHDBC)

Example

S SQLCODE=$$AC^SQLOS(SQLHENV,.SQLHDBC)

I SQLCODE'=0 D Error Q

Notes

• This function requires a valid environment handle (SQLHENV).

• A valid connection handle (SQLHDBC) is returned by the function.

• You need a connection handle to store information about the connection.

• A connection can contain multiple statement handles.

SQLAllocEnv

Allocates an environment handle.

Arguments

None

Returns

Return code [SQLCODE]

Environment handle [SQLHENV]

Syntax

SQLCODE=$$AE^SQLOS(.SQLHENV)

Example

S SQLCODE=$$AE^SQLOS(.SQLHENV)

I SQLCODE'=0 D Error Q

Notes

• A valid environment handle (SQLHENV) is returned by the function.

• You need an environment handle to store information about the environment.

• An environment can contain multiple connection handles.

SQLAllocStmt

Allocates a statement handle.

Arguments

Connection handle [SQLHDBC]

Returns

Return code [SQLCODE]

Statement handle [SQLHSTMT]

Syntax

SQLCODE=$$AS^SQLOS(SQLHDBC,.SQLHSTMT)

Example

Page 44: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

40

S SQLCODE=$$AS^SQLOS(SQLHDBC,.SQLHSTMT)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function requires a valid connection handle (SQLHDBC).

• A valid statement handle (SQLHSTMT) is returned by the function.

• You need a statement handle to prepare and execute an SQL command.

SQLBindCol

Binds a select expression to a host variable.

Arguments

Statement handle [SQLHSTMT]

Column sequence [SQLCOL]

Column name [NAME]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$BC^SQLOS(SQLHSTMT,SQLCOL,NAME)

Example

S SQLCODE=$$BC^SQLOS(SQLHSTMT,2,"CNAME")

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function cannot occur prior to statement preparation.

• The SQLFetch function places data into the host variable.

• If a column sequence is 0, all columns in the array are bound by the name

parameter and sequenced by the actual column number. Consider

$$BC^SQLOS(SQLHSTMT, 0, "XYZ"). Each fetch operation returns the local

array XYZ populated with all columns from the result set. For example, SELECT

NAME, SEX, DOB FROM PATIENT yields:

XYZ(1) = name

XYZ(2) = sex

XYZ(3) = dob

SQLBindParameter

Declares the data type for a parameter.

Arguments

Statement handle [SQLHSTMT]

Parameter sequence [SEQ]

ODBC data type [TYPE]

Returns

Return code [SQLCODE]

Syntax

Page 45: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

41

SQLCODE=$$BP^SQLOS(SQLHSTMT,SEQ,TYPE)

Example

S SQLCODE=$$BP^SQLOS(SQLHSTMT,1,1)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function is equivalent to the SQLSetParam function from ODBC V1.0.

• The data type is the numeric value of the ODBC data type.

• Run the on-line query SQL_API_DATATYPE to generate a list of supported data

types.

SQLCancel

Cancels a statement.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$CS^SQLOS(SQLHSTMT)

Example

S SQLCODE=$$CS^SQLOS(SQLHSTMT)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function is primarily useful when asynchronous processing is enabled.

SQLColAttributes

Returns information on a particular feature of a column.

Arguments

Statement handle [SQLHSTMT]

Column sequence [SQLCOL]

Descriptor type [SQLDESC]

Returns

Return code [SQLCODE]

Descriptor value [VALUE]

Syntax

SQLCODE=$$CA^SQLOS(SQLHSTMT,SQLCOL,SQLDESC,.VALUE)

Example

S SQLCODE=$$CA^SQLOS(SQLHSTMT,3,1,.NAME)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function provides more information than SQLDescribeCol.

See SQLColAttributes Descriptor Code

SQL_COLUMN_COUNT 0

Page 46: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

42

SQL_COLUMN_NAME 1.

SQL_COLUMN_TYPE 2.

SQL_COLUMN_LENGTH 3.

SQL_COLUMN_PRECISION 4.

SQL_COLUMN_SCALE 5.

SQL_COLUMN_DISPLAY_SIZE 6.

SQL_COLUMN_UNSIGNED 8

SQL_COLUMN_MONEY 9

SQL_COLUMN_UPDATABLE 10

SQL_COLUMN_AUTO_INCREMENT 11

SQL_COLUMN_CASE_SENSITIVE 12

SQL_COLUMN_SEARCHABLE 13

SQL_COLUMN_TYPE_NAME 14

SQL_COLUMN_TABLE_NAME 15

SQL_COLUMN_OWNER_NAME 16

SQL_COLUMN_QUALIFIER_NAME 17

SQL_COLUMN_COLUMN_LABEL 18

SQLColumnPrivileges

SQLColumnPrivileges returns a list of columns and associated privileges for the

specified table.

Note: This function is implemented but not yet supported.

Arguments

Statement handle [SQLHSTMT]

TableQualifier [QUAL]

TableOwner [OWNER]

TableName [TABLE]

ColumnName [COLUMN]

Returns

Return code [SQLCODE]

Syntax

S SQLCODE=$$CM^SQLOS(SQLHSTMT,QUAL,OWNER,TABLE,COLUMN)

Notes

Page 47: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

43

• The ColumnName argument accepts a search pattern.

• This function will return an empty result set until the product supports column-

level privileges within the KB_SQL Engine.

SQLColumns

Returns the list of column names in specified tables.

Arguments

Statement handle [SQLHSTMT]

Table qualifier [QUAL]

Table owner [OWNER]

Table name [TABLE]

Column name [COLUMN]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$CM^SQLOS(SQLHSTMT,QUAL,OWNER,TABLE,COLUMN)

Example

S

SQLCODE=$$CM^SQLOS(SQLHSTMT,"","SQL_TEST","EMPLOYEES","%"

)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• SQLColumns does not return columns for an index table. Use the SQLStatistics

function to return the columns of an index table.

• This function returns a result set (see the next page) that can be processed like any

other query result.

SQLConnect

Connects to KB_SQL server.

Arguments

Data source name [SQLDATAS]

User name [SQLUNAME]

Authorization [SQLUAUTH]

Returns

Return code [SQLCODE]

Connection handle [SQLHDBC]

Syntax

SQLCODE=$$C^SQLOS(SQLDATAS,SQLUNAME,SQLUAUTH,.SQLHDBC)

Example

S SQLCODE=$$C^SQLOS("M","DBA","SHARK",.SQLHDBC)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

Page 48: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

44

• The data source name parameter is not currently validated by the Server API.

• If you are using the API for M, set the data source name parameter to "M".

• If you are using the API for C, the data source name parameter takes the value of

the entry in the ODBC.INI configuration file.

SQLDescribeCol

Gets basic metadata on a column.

Arguments

Statement handle [SQLHSTMT]

Column sequence [SQLCOL]

Returns

Return code [SQLCODE]

Column name [NAME]

ODBC data type [TYPE]

Precision [PRECISION]

Scale [SCALE]

Nullable [NULLABLE]

Syntax

SQLCODE=$$DC^SQLOS(SQLHSTMT,SQLCOL,.NAME,.TYPE,.PREC,.SCALE

,.NULLABLE)

Example

S COL=3

S

SQLCODE=$$DCSQLOS(SQLHSTMT,COL,.NAME,.TYPE,.PREC,.SCALE,.NUL

LABLE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the variable COL to get column data dictionary information for

the third column in the result set. Note that COL is a number where 1 <= COL

<= NumResultCols.

• This function is an easier form of the more complete SQLColAttributes function.

SQLDescribeParam

SQLDescribeParam returns the description of a parameter marker associated with a

prepared SQL statement.

Arguments

Statement handle [SQLHSTMT]

Parameter sequence [PARSEQ]

SqlType [TYPE]

Precision [PREC]

Scale [SCALE]

Nullable [NULLABLE]

SQL_NO_NULLS(0)

The parameter does not allow NULL values. (This is the default value).

SQL_NULLABLE(1)

Page 49: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

45

The parameter allows NULL values.

SQL_NULLABLE_UNKNOWN(2)

The driver cannot determine if the parameter allows NULL values.

Syntax

S SQLCODE=$$DP^SQLOS(SQLHSTMT,PARSEQ,.TYPE,.PREC,.SCALE,

.NULLABLE)

SQLDisconnect

Disconnects from KB_SQL Server.

Arguments

Connection handle [SQLHDBC]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$D^SQLOS(SQLHDBC)

Example

DISCON S SQLCODE=$$D^SQLOS(SQLHDBC)

I SQLCODE'=0 D Error

Notes

• All connection statement handles are dropped.

• In the KB_SQL API for C, this function causes a network disconnect.

SQLError

Returns error information.

Arguments

Connection handle [SQLHDBC]

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Sqlstate [SQLSTATE]

Native code [SQLNC]

Native error text [SQLNT]

Syntax

SQLCODE=$$ER^SQLOS(SQLHDBC,SQLHSTMT,.SQLSTATE,.SQLNC,.SQLN

T)

Example

ER ; SQLError

3. I SQLCODE=99!(SQLCODE=100) Q

Page 50: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

46

W !,"SQLCODE= ",SQLCODE,! N SQLCODE,K65,ERS,ERC,ERT I

'$G(SQLHDBC) S SQLHDBC=0

I '$G(SQLHSTMT) S SQLHSTMT=0

4. S SQLCODE=$$ER^SQLOS(SQLHDBC,SQLHSTMT,.ERS,.ERC,.ERT) I

SQLCODE<0 Q

I SQLCODE=100 Q

W "SQLSTATE= ",ERS

I ERS="" G 5

S K65=$O(^SQL(65,-1,ERS,0)) W " ",^SQL(65,K65,2)

5. W !,"Error Code= ",ERC,!,"Error Text= ",ERT,! G 4

6. Q

SQLExecDirect

Prepares and executes an SQL command.

Arguments

Statement handle [SQLHSTMT]

SQL command [SQLTEXT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$ED^SQLOS(SQLHSTMT,SQLTEXT)

Example

S SQLCODE=$$ED^SQLOS(SQLHSTMT,"SELECT * FROM

SQL_TEST.EMPLOYEES")

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function can be used in place of SQLPrepare and SQLExecute.

SQLExecute

Executes a previously prepared SQL command.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$E^SQLOS(SQLHSTMT)

Example

S SQLCODE=$$E^SQLOS(SQLHSTMT)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

Page 51: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

47

• If your query includes parameters, the SQLExecute function can return

"SQLCODE=99," which indicates that data needs to be provided for parameters.

At this point, you would invoke SQLPutData until SQLCODE is not equal to 99.

Refer to the illustration in the Error Processing section earlier in this chapter.

SQLFetch

Advances the cursor position for a statement.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$F^SQLOS(SQLHSTMT)

Example

1. S SQLCODE=$$F^SQLOS(SQLHSTMT)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

I SQLCODE=100 G 2

.

.

.

G 1

2. .

Notes

• This function automatically populates all bound columns for each row.

SQLForeignKeys

SQLForeignKeys can return:

• A list of foreign keys in the specified table (columns in the specified table that

refer to primary keys in other tables).

• A list of foreign keys in other tables that refer to the primary key in the specified

table.

Arguments

Statement handle [SQLHSTMT]

PkTableQualifier [PKQUAL]

PkTableOwner [PKOWNER]

PkTableName [PKTABLE]

Page 52: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

48

FkTableQualifier [FKQUAL]

FkTableOwner [FKOWNER]

FkTableName [FKTABLE]

Syntax

S SQLCODE=$$FK^SQLOS(SQLHSTMT,PKQUAL,PKOWNER,PKTABLE,

FKQUAL,FKOWNER,FKTABLE)

Notes

• If PkTableName contains a table name, SQLForeignKeys returns a result set

containing the primary key of the specified table and all of the foreign keys that

refer to it. The result set is ordered by PKTABLE_QUALIFIER,

PKTABLE_OWNER, PKTABLE_NAME, and KEY_SEQ.

Example: To obtain a list of foreign keys that refer to the PATIENT table.

S SQLCODE=$$FK^SQLOS(SQLHSTMT,””,””,”PATIENT”,””,””,””)

• If FkTableName contains a table name, SQLForeignKeys returns a result set

containing all of the foreign keys in the specified table and the primary keys (in

other tables) to which they refer. The result set is ordered by

FKTABLE_QUALIFIER, FKTABLE_OWNER, FKTABLE_NAME, and

KEY_SEQ.

Example: To obtain a list of foreign keys stored in the PATIENT table.

S SQLCODE=$$FK^SQLOS(SQLHSTMT,””,””,””,””,””,”PATIENT”)

• If both PkTableName and FkTableName contain table names, SQLForeignKeys

returns the foreign keys in the table specified in FkTableName that refer to the

primary key of the table specified in PkTableName.

Example: To obtain a list of the one foreign key that joins the PATIENT and VISIT

tables.

S SQLCODE=$$FK^SQLOS(SQLHSTMT,””,””,”PATIENT”,””,””,”VISIT”)

Result Set

Column Name Description

PKTABLE_QUALIFIER Primary key table qualifier identifier.

PKTABLE_OWNER Primary key table owner identifier.

PKTABLE_NAME Primary key table identifier.

PKCOLUMN_NAME Primary key column identifier.

FKTABLE_QUALIFIER Foreign key table qualifier identifier.

FKTABLE_OWNER Foreign key table owner identifier.

FKTABLE_NAME Foreign key table identifier.

FKCOLUMN_NAME Foreign key column identifier.

KEY_SEQ Column sequence number in key (starting with 1).

UPDATE_RULE Action to be applied to the foreign key on UPDATE.

Page 53: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

49

SQL_CASCADE

SQL_RESTRICT

SQL_SET_NULL

NULL

DELETE_RULE Action to be applied to the foreign key on DELETE.

SQL_CASCADE

SQL_RESTRICT

SQL_SET_NULL

NULL if not applicable

FK_NAME Foreign key identifier.

PK_NAME Primary key identifier.

Related Functions

Sample routine SQLJ16.

SQLFreeConnect

Frees the connection handle and all associated statement handles.

Arguments

Connection handle [SQLHDBC]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$FC^SQLOS(SQLHDBC)

Example

S SQLCODE=$$FC^SQLOS(SQLHDBC)

I SQLCODE'=0 D Error Q

Note

• This function effectively closes all active statements and drops the connection.

SQLFreeEnv

Frees the environment handle and all associated connection and statement handles.

Arguments

Environment handle [SQLHENV]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$FE^SQLOS(SQLHENV)

Example

S SQLCODE=$$FE^SQLOS(SQLHENV)

I SQLCODE'=0 D Error Q

Notes

Page 54: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

50

• This function effectively closes all active statements and active connections and

drops the environment.

SQLFreeStmt

Stops processing of a statement, closes any open cursors associated with that statement,

and discards results.

Arguments

Statement handle [SQLHSTMT]

Option [SQLTYPE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$FS^SQLOS(SQLHSTMT,SQLTYPE)

Example

S SQLCODE=$$FS^SQLOS(SQLHSTMT,1)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Options

SQLFreeStmt Option Code

SQL_CLOSE 0

SQL_DROP 1.

SQL_UNBIND 2.

SQL_RESET_PARAMS 3.

SQLGetConnectOption

Returns the current setting of a connection option.

Arguments

Connection handle [SQLHDBC]

Option type [TYPE]

Returns

Return code [SQLCODE]

Option value [VALUE]

Syntax

SQLCODE=$$GCO^SQLOS(SQLHDBC,TYPE,.VALUE)

Example

S OPTION=101

S SQLCODE=$$GCO^SQLOS(SQLHDBC,OPTION,.VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the variable OPTION to get information about the

SQL_ACCESS_MODE state for the connection referenced by the variable

SQLHDBC.

Page 55: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

51

• See SQLSetConnectOption for a list of statement options for this function.

• Run SQL_API_CONNECT_OPTION to generate a list of connection options.

SQLGetCursorName

Returns the name of a cursor associated with a statement.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Cursor name [NAME]

Syntax

SQLCODE=$$GCN^SQLOS(SQLHSTMT,.NAME)

Example

S SQLCODE=$$GCN^SQLOS(SQLHSTMT,.NAME)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The only statements that use a cursor name are the positioned UPDATE and

DELETE (for example, UPDATE table-name...WHERE CURRENT OF cursor-

name).

• If the application does not call SQLSetCursorName, the SQL engine allocates a

default cursor name.

• This function returns the name of a cursor regardless of whether it was created

explicitly or implicitly.

SQLGetData

Returns a specific column value from a statement cursor.

Arguments

Statement handle [SQLHSTMT]

Column sequence [SQLCOL]

Returns

Return code [SQLCODE]

Column value [VALUE]

Syntax

SQLCODE=$$GD^SQLOS(SQLHSTMT,SQLCOL,.VALUE)

Example

S SEQ=3

S SQLCODE=$$GD^SQLOS(SQLHSTMT,SEQ,.VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example gets the value of the result set’s third column, (SEQ), for the

statement referenced by the variable SQLHSTMT. Note that SEQ is a number

where 1<= SEQ <= NumResultCols.

• See also SQLBindCol.

• We recommend SQLFetch for better performance.

Page 56: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

52

SQLGetInfo

Returns general information about the driver and data source.

Arguments

Connection handle [SQLHDBC]

Info type [TYPE]

Returns

Return code [SQLCODE]

Info value [VALUE]

Syntax

SQLCODE=$$GI^SQLOS(SQLHDBC,TYPE,.VALUE)

Example

S SQLCODE=$$GI^SQLOS(SQLHDBC,TYPE,.VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• Run the on-line query, SQL_API_INFO_OPTION, to generate a list of the

SQLGetInfo options and their respective codes.

• See sample routine SQLJ10 for an illustration of how to use SQLGetInfo.

• The ODBC specification reserves the range of 0-999 for information types.

• KBS reserves values greater than 1000 for data source specific information.

• A returned value is always a simple string of numbers or characters.

• A bitmask requires special handling. Two subroutines, UNMASK ^SQLK4 and

MASK^SQLK4, are provided to assist in this process.

For example, suppose you receive a BitMask value of 1431655765. The following code

demonstrates the effect of the two subroutines:

; Convert Number to BitString

S X=65535

D MASK^SQLK4

W X ; Returns "00000000000000001111111111111111"

; Convert BitString to Number

S X="00000000000000001111111111111111"

D UNMASK^SQLK4

W X ; Returns 65535

SQLGetStmtOption

Returns the current settings of a statement option.

Arguments

Statement handle [SQLHSTMT]

Statement option [OPTION]

Returns

Return code [SQLCODE]

Option value [VALUE]

Page 57: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

53

Syntax

SQLCODE=$$GSO^SQLOS(SQLHSTMT,OPTION,.VALUE)

Example

S TYPE=0

S SQLCODE=$$GSO^SQLOS(SQLHSTMT,TYPE,.VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the variable TYPE to get information about the statement

option for the statement referenced by the variable SQLHSTMT.

• For a list of valid statement options, run the on-line query

SQL_API_STATEMENT_OPTION or see the SQLSetStmtOption function.

SQLGetTypeInfo

Returns information on supported data types.

Arguments

Statement handle [SQLHSTMT]

ODBC data type [TYPE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$GTI^SQLOS(SQLHSTMT,TYPE)

Example

S TYPE=-7

S SQLCODE=$$GTI^SQLOS(SQLHSTMT,TYPE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example produces a result set of information about the SQL_BIT(FLAG)

data type.

• If the TYPE variable is zero (0), the result set contains information about all

supported types. Otherwise, the result set is specific to the one type referenced by

the TYPE variable.

• Run the on-line query, SQL_API_DATATYPE, to generate a list of supported

data types.

• See sample routine SQLJ6 for a demonstration of SQLGetTypeInfo.

SQLMoreResults

SQLMoreResults determines whether there are more results available on an hstmt

containing SELECT, UPDATE, INSERT, or DELETE statements and, if so, initializes

processing for those results.

Arguments

Statement handle [SQLHSTMT]

Syntax

S SQLCODE=$$MR^SQLOS(SQLHSTMT)

Page 58: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

54

Notes

• UPDATE, INSERT, and DELETE statements return a count of affected rows. If

any of these statements are batched, submitted with arrays of parameters, or in

procedures, they can return multiple result sets or counts.

• If another result set or count is available, SQLMoreResults returns

SQL_SUCCESS and initializes the result set or count for additional processing.

After calling SQLMoreResults for SELECT statements, an application can call

functions to determine the characteristics of the result set and to retrieve data from

the result set. After calling SQLMoreResults for UPDATE, INSERT, or DELETE

statements, an application can call SQLRowCount.

• If all results have been processed, SQLMoreResults returns

SQL_NO_DATA_FOUND.

• Note that if there is a current result set with unfetched rows, SQLMoreResults

discards that result set and makes the next result set or count available.

• If a batch of statements or a procedure mixes other SQL statements with

SELECT, UPDATE, INSERT, and DELETE statements, these other statements

do not affect SQLMoreResults.

SQLNativeSql

SQLNativeSql returns the SQL command text as translated by the server.

Arguments

Connection handle [SQLHDBC]

LinesIn [IN]

ArrayIn [XIN]

LinesOut [OUT]

ArrayOut [XOUT]

Syntax

S SQLCODE=$$NS^SQLOS(SQLHDBC,IN,XIN,.OUT,XOUT)

Notes

The SQLNativeSql function returns the SQL command text after it has been processed to

handle ODBC escape clauses and string literal quoting. A summary of the conversions is

listed below.

{fn function(parmlist)}

SQL_function(parmlist)

{fn lower(Name)}

=> SQL_lower(Name)

{d date-literal}

date-literal

{d '1996-07-15'}

=> '1996-07-15'

{t time-literal}

time-literal

{t '22:30:15'}

=> '22:30:15'

Page 59: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

55

{ts timestamp-literal}

timestamp-literal

{ts '1996-07-15 22:30:15'}

=> '1996-07-15 22:30:15'

{call procedure(parmlist)}

call procedure(parmlist)

{call DeptEmps(?)}

=> call DeptEmps(?)

DoubleQuote in SingleQuoted Literal

'hello "there" world'

=> 'hello ""there"" world'

SingleQuote in DoubleQuoted Literal

"hello 'there' world"

=> "hello ''there'' world"

SoftTag in Literal

'hello {*there} world'

=> ('hello '|chr(123,42)|'there} world')

Related Functions

Sample routine SQLJ21.

Example

Enter SQL Command (or 'GO' to execute)

-->Select {fn lcase(name)}, {fn soundex(name)}

-->From Employees

-->Where {fn floor(salary)} > 10

-->go

SQL Statement converted to native syntax

Select SQL_fn_lcase(name), SQL_fn_soundex(name)

From Employees

Where SQL_fn_floor(salary) > 10

SQLNumParams

SQLNumParams returns the number of parameters in an SQL statement.

Arguments

Statement handle [SQLHSTMT]

numParams [NPM]

Syntax

S SQLCODE=$$NP^SQLOS(SQLHSTMT,.NPM)

Notes

• SQLNumParams can be called only after SQLPrepare has been called.

• If the statement associated with hstmt does not contain parameters,

SQLNumParams sets numParams to 0.

Related Functions

Page 60: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

56

Sample routine SQLJ21.

SQLDescribeParam API function.

SQLNumResultCols

Returns the number of columns in a table.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Number of columns [COLS]

Syntax

SQLCODE=$$NRC^SQLOS(SQLHSTMT,.COLS)

Example

S SQLCODE=$$NRC^SQLOS(SQLHSTMT,.NRC)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the NRC variable to return the number of result columns in the

statement referenced by the SQLHSTMT variable.

• Note that the statement must be prepared prior to execution of this function,

otherwise an error will result.

SQLPrepare

Prepares an SQL command for execution.

Arguments

Statement handle [SQLHSTMT]

SQL command [SQLTEXT]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$P^SQLOS(SQLHSTMT,SQLTEXT)

Example

S SQLCODE=$$P^SQLOS(SQLHSTMT,"SELECT * FROM

SQL_TEST.EMPLOYEES")

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• If the SQL command is too long (greater than 255 bytes) to be prepared all at

once, use KBSStatement.

SQLPrimaryKeys

SQLPrimaryKeys returns the column names that comprise the primary key for a table.

Arguments

Statement handle [SQLHSTMT]

Page 61: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

57

TableQualifier [QUAL]

TableOwner [OWNER]

TableName [TABLE]

Syntax

S SQLCODE=$$PK^SQLOS(SQLHSTMT,QUAL,OWNER,TABLE)

Notes

SQLPrimaryKeys returns the results as a standard result set, ordered by

TABLE_QUALIFIER, TABLE_OWNER, TABLE_NAME, and KEY_SEQ.

SQLProcedureColumns

SQLProcedureColumns returns the list of input and output parameters, as well as the

columns that make up the result set for the specified procedures.

Arguments

Statement handle [SQLHSTMT]

ProcQualifier [QUAL]

ProcOwner [OWNER]

ProcName [PROC]

ColumnName [COLUMN]

Syntax

S SQLCODE=$$PC^SQLOS(SQLHSTMT,QUAL,OWNER,PROC,COLUMN)

Notes

• This function is typically used before statement execution to retrieve information

about procedure parameters and columns from the system catalog.

• The procedure query must be compiled in order for the procedure to be

recognized.

• The ProcOwner, ProcName, and ColumnName arguments accept wildcard search

patterns.

SQLProcedures

SQLProcedures returns the list of procedure names stored in a specific data source.

Procedure is a generic term used to describe an executable object, or a named entity that

can be invoked using input and output parameters, and which can return result sets

similar to the results returned by SQL SELECT expressions.

Arguments

Statement handle [SQLHSTMT]

ProcQualifier [QUAL]

ProcOwner [OWNER]

ProcName [PROC]

Syntax

S SQLCODE=$$PR^SQLOS(SQLHSTMT,QUAL,OWNER,PROC)

Page 62: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

58

Notes

• SQLProcedures lists all procedures in the requested range.

• A user may or may not have permission to execute any of these procedures. To

check accessibility, an application can call SQLGetInfo and check the

SQL_ACCESSIBLE_PROCEDURES information value. Otherwise, the

application must be able to handle a situation where the user selects a procedure

which it cannot execute.

• The procedure query must be compiled in order for the procedure to be

recognized.

• The ProcOwner and ProcName arguments accept wildcard search patterns.

SQLPutData

Specifies the execution time value for a parameter.

Arguments

Statement handle [SQLHSTMT]

Parameter value [VALUE]

Parameter sequence [SEQ]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$PD^SQLOS(SQLHSTMT,VALUE,SEQ)

Example

S SQLCODE=$$PD^SQLOS(SQLHSTMT,"9.00",2)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• In the case of date, time, timestamp, and bit, the value parameter is in the external

format used by ODBC. For example, a date parameter is specified as "1995-04-

28" as opposed to the internal format for M dates.

• Note that the SQL_BIT type is mapped to the KBS FLAG data type.

SQLRowCount

Returns the number of rows from a result set.

Arguments

Statement handle [SQLHSTMT]

Returns

Return code [SQLCODE]

Number of rows [ROWS]

Syntax

SQLCODE=$$RC^SQLOS(SQLHSTMT,.ROWS)

Example

S SQLCODE=$$RC^SQLOS(SQLHSTMT,.ROWS)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

Page 63: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

59

• This function is designed for use with INSERT, UPDATE, and DELETE queries.

• It returns the number of rows affected by the query.

• For a SELECT query, this function returns the current row number.

SQLSetConnectOption

Sets options that govern aspects of connections.

Arguments

Connection handle [SQLHDBC]

Option type [TYPE]

Option value [VALUE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$SCO^SQLOS(SQLHDBC,TYPE,VALUE)

Example

S TYPE=101,VALUE=1

S SQLCODE=$$SCO^SQLOS(SQLHDBC,TYPE,VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the variable TYPE to set the value SQL_ACCESS_MODE

option to read only for the connection referenced by the variable SQLHDBC.

• Run the on-line query SQL_API_CONNECT_OPTION to generate a list of

connection options.

• See the accompanying table on the next page for a list of this function’s statement

options and their respective codes.

Options

SQLSetConnectOption Option Code

SQL_ACCESS_MODE 101

SQL_AUTOCOMMIT 102

SQL_LOGIN_TIMEOUT 103

SQL_OPT_TRACE 104

SQL_OPT_TRACEFILE 105

SQL_TRANSLATE_DLL 106

SQL_TRANSLATE_OPTION 107

SQL_TXN_ISOLATION 108

SQL_CURRENT_QUALIFIER 109

SQL_ODBC_CURSORS 110

SQL_QUIET_MODE 111

SQL_PACKET_SIZE 112

SQL_CONNECT_OPT_DRVR_START 1000

Page 64: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

60

SQLSetCursorName

Specifies the name of a cursor for a statement.

Arguments

Statement handle [SQLHSTMT]

Cursor name [NAME]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$SCN^SQLOS(SQLHSTMT,NAME)

Example

S SQLCODE=$$SCN^SQLOS(SQLHSTMT,NAME)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• All cursor names within the connection must be unique.

• The only statements that use a cursor name are the positioned UPDATE and

DELETE (for example, UPDATE table-name...WHERE CURRENT OF cursor-

name).

• If the application does not call SQLSetCursorName, the SQL engine allocates a

default cursor name.

• This function returns the name of a cursor regardless of whether it was created

explicitly or implicitly.

SQLSetStmtOption

Sets options related to statement handle.

Arguments

Statement handle [SQLHSTMT]

Statement option [OPTION]

Option value [VALUE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$SSO^SQLOS(SQLHSTMT,OPTION,VALUE)

Example

S OPTION=0,VALUE=60

S SQLCODE=$$SSO^SQLOS(SQLHSTMT,OPTION,VALUE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example uses the variable OPTION to set the SQL_QUERY_TIMEOUT

value for the statement referenced by the variable SQLHSTMT.

• For a list of valid statement options, run the on-line query

SQL_API_STATEMENT_OPTION or see the table on the next page.

Page 65: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

61

Options

SQLSetStmtOption Option Code

SQL_QUERY_TIMEOUT 0

SQL_MAX_ROWS 1.

SQL_NOSCAN 2.

SQL_MAX_LENGTH 3.

SQL_ASYNC_ENABLE 4.

SQL_BIND_TYPE 5.

SQL_CURSOR_TYPE 6.

SQL_CONCURRENCY 7.

SQL_KEYSET_SIZE 8.

SQL_ROWSET_SIZE 9.

SQL_SIMULATE_CURSOR 1.

SQL_RETRIEVE_DATA 1.

SQL_USE_BOOKMARKS 1.

SQL_GET_BOOKMARK 1.

SQL_ROW_NUMBER 1.

SQLSpecialColumns

Returns row identity and auto-updates columns.

Arguments

Statement handle [SQLHSTMT]

Column type [COLTYPE]

Table qualifier [QUAL]

Table owner [OWNER]

Table name [TABLE]

Scope [SCOPE]

Nullable [NULLABLE]

Returns

Page 66: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

62

Return code [SQLCODE]

Syntax

SQLCODE=$$SC^SQLOS(SQLHSTMT,COLTYPE,QUAL,OWNER,TABLE,SCO

PE,NULLABLE)

Example

S SQLCODE=$$SC^SQLOS(SQLHSTMT,1,"","SQL_TEST","CHARGES",0,0)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• This function returns the primary keys for the table.

• See the accompanying table on the next page for the result set.

Result Set

SQLSpecialColumns Column Col Seq

SCOPE 1.

COLUMN_NAME 2.

DATA_TYPE 3.

TYPE_NAME 4.

PRECISION 5.

LENGTH 6.

SCALE 7.

PSEUDO_COLUMN 8.

SQLStatistics

Returns the primary key for a base table and for an index table. Because the primary key

is all the columns for an index table, you can use this function to get all the columns in an

index table, but not all the columns in a base table.

Arguments

Statement handle [SQLHSTMT]

Table qualifier [QUAL]

Table owner [OWNER]

Table name [TABLE]

Unique [UNIQUE]

Accuracy [ACCURACY]

Returns

Return code [SQLCODE]

Page 67: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

63

Syntax

SQLCODE=$$SM^SQLOS(SQLHSTMT,QUAL,OWNER,TABLE,UNIQUE,ACC

URACY)

Example

S SQLCODE=$$SM^SQLOS(SQLHSTMT,"","SQL_TEST","EMPLOYEES",1,1)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• See the accompanying table on the next page for the result set.

Result Set

SQLStatistics Column Col Seq

TABLE_QUALIFIER 1.

TABLE_OWNER 2.

TABLE_NAME 3.

NON_UNIQUE 4.

INDEX_QUALIFIER 5.

INDEX_NAME 6.

TYPE 7.

SEQ_IN_INDEX 8.

COLUMN_NAME 9.

COLLATION 1.

CARDINALITY 1.

PAGES 1.

FILTER_CONDITION 1.

SQLTablePrivileges

SQLTablePrivileges returns a list of tables and the privileges associated with each table.

Arguments

Statement handle [SQLHSTMT]

Page 68: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

64

TableQualifier [QUAL]

TableOwner [OWNER]

TableName [TABLE]

Notes

• The TableOwner and TableName arguments accept search patterns.

• For the DBA, privileges will appear for all grantees.

• For non-DBA users, privileges will appear for your user group only.

Result Set

Column Name Description

TABLE_QUALIFIER Table qualifier identifier.

TABLE_OWNER Table owner identifier.

TABLE_NAME Table identifier.

GRANTOR User who granted the privilege.

GRANTEE User to whom the privilege was granted.

PRIVILEGE Identifies the table privilege.

SELECT The grantee is permitted to retrieve data for one or more

INSERT The grantee is permitted to insert new rows containing

UPDATE The grantee is permitted to update the data in one or

DELETE The grantee is permitted to delete rows of data from the

REFERENCES The grantee is permitted to refer to one or more columns of the

table within a constraint (for example, a unique, referential, or

table check constraint). The scope of action permitted the grantee

by a given table privilege is data source-dependent. For example,

the UPDATE privilege might permit the grantee to update all

columns in a table on one data source and only those columns for

which the grantor has the UPDATE privilege on another data

source.

IS_GRANTABLE Indicates whether the grantee is permitted to grant the privilege

to other users: YES, NO, or NULL if unknown.

Related Functions

Sample routine SQLJ20.

SQLTables

Returns list of table names stored in a specific data source. The list includes only those

tables accessible by the user who is currently logged in via the SQLConnect function. To

get the complete list of tables you must log in as the DBA.

Arguments

Statement handle [SQLHSTMT]

Table Qualifier [QUAL]

Page 69: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Programming Considerations

65

Table Owner [OWNER]

Table Name [TABLE]

Table Type [TYPE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$TM^SQLOS(SQLHSTMT,QUAL,OWNER,TABLE,TYPE)

Example

;List all Owners (schemas)

S SQLCODE=$$TM^SQLOS(HSTMT,"","%","","")

;List Types

S SQLCODE=$$TM^SQLOS(HSTMT,"","","","%")

;List Views

S SQLCODE=$$TM^SQLOS(HSTMT,"","","%","VIEW")

;List Tables

S SQLCODE=$$TM^SQLOS(HSTMT,"","","%","TABLE")

;List System Tables

S SQLCODE=$$TM^SQLOS(HSTMT,"","","%","SYSTEM TABLE")

Notes

• The table qualifier (QUAL) argument is supported, but its value must be null.

• You may use the subroutine WCPD^SQLK4 to pad or insert wildcards into an

SQL_IDENTIFIER.

For example, assume the following SQL_IDENTIFIER is a valid table name.

THIS_IS_MY_VALID_TABLENAME

The WCPD subroutine may be called to insert the wildcard escape character as illustrated

below.

>w X

THIS_IS_MY_VALID_TABLENAME

>D WCPD^SQLK4

/* After conversion */

>W X

THIS\_IS\_MY\_VALID\_TABLENAME

The result set of the function appears below.

Result Set

SQLTables Column Col Seq

TABLE_QUALIFIER 1.

TABLE_OWNER 2.

TABLE_NAME 3.

TABLE_TYPE 4.

Page 70: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

66

REMARKS 5.

SQLTransact

Commits or rolls back pending transactions.

Arguments

Connection handle [SQLHDBC]

Commit or rollback [SQLTTYPE]

Returns

Return code [SQLCODE]

Syntax

SQLCODE=$$T^SQLOS(SQLHDBC,SQLTTYPE)

Example

S TTYPE=1

SQLCODE=$$T^SQLOS(SQLHDBC,TTYPE)

I SQLCODE'=0 D Error G:SQLCODE<0 Discon

Notes

• The example attempts to rollback the transaction for the connection. TTYPE can

be zero (0) for commit, or one (1) for rollback.

• Users are encouraged to use this API call instead of the SQL COMMIT and

ROLLBACK commands to commit or rollback pending transactions.

Options

SQLTransact Option Code

COMMIT 0

ROLLBACK 1.

ActiveX Data Objects (ADO)

Overview of ADO Programming

Programming using ADO with KB_SQL is just as it is for using ADO with any other

SQL Data Source.

See www.microsoft.com/data for more information.

Page 71: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

67

Appendixes

A - Escape Sequences

Extensions

SQL Extensions

KB_SQL API supports several ODBC SQL extensions:

• the representation of date and time literals

• the syntax for scalar functions

• LIKE predicate escape characters

• stored procedures

These extensions provide essential functionality that is shared by most DBMSs.

However, because the syntax required by the DBMSs varies, ODBC uses a syntactical

notation called the escape clause. The escape clause consists of a pair of curly braces {}

which surround the standard SQL syntax form and a token which specifies the type of

clause.

Date, Time, and TimeStamp

Date, Time, and Timestamp Data

KB_SQL API supports the DATE, TIME, and TIMESTAMP (a combined form of DATE

and TIME) data types. The shorthand escape clause syntax for these data types is:

{d 'value'} {d '1999-04-28'} April 28, 1999

{t 'value'} {t '10:30:00'} 10:30 AM

{ts 'value'} {ts '1999-04-28 10:30:00'} April 28, 1999 at 10:30 AM

Wildcards

Wildcards (Search Pattern Escape Characters)

ODBC supports wildcards using the underscore character (_) for single-character

replacement and the percent sign (%) for multiple-character replacement.

A word of caution is in order with respect to the use of wildcards, particularly in relation

to the various catalog functions where the SQL_IDENTIFIER can include the underscore

character. When you want to use a meta character as a literal and not as a wildcard, you

must precede the meta character with the search pattern escape character (the default is

the backward slash).

Page 72: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

68

For example, to obtain all columns for the LAB_PATIENT table where the underscore is

a literal in the SQL_IDENTIFIER, you send the table name parameter as:

LAB\_PATIENT

Using the escape character prevents the engine from interpreting the underscore as a

wildcard, thus avoiding retrieving columns for tables that could be named LABaTABLE,

LABbTABLE, and so forth.

Scalar functions

Scalar Functions

Scalar (or row) functions operate on a single value. They include functions that compute

absolute value or length, format a date or time, or return a substring. The on-line query

SQL_FUNCTION_LIST provides a complete list of the KB_SQL API scalar functions

and their syntax.

Function Description

SQL_FN_ABS(numeric_exp) Returns absolute value

SQL_FN_ASCII(string_exp) Returns the ASCII code

value of the leftmost

character

SQL_FN_CEILING(numeric_exp) Returns smallest integer

greater or equal to value

SQL_FN_CHAR(code) Returns the character of the

ASCII code

SQL_FN_CONCAT(string_exp1, string_exp2) Concatenates two values

using SQL rules

SQL_FN_DAYNAME(date_exp) Returns day name

SQL_FN_DAYOFMONTH(date_exp) Returns day of month based

on date value

SQL_FN_DAYOFWEEK(date_exp) Returns day of week

(1=Sunday)

SQL_FN_DAYOFYEAR(date_exp) Returns day of year

SQL_FN_DIFFERENCE(string_exp1, string_exp2) Difference in Soundex

codes

SQL_FN_FLOOR(numeric_exp) Returns largest integer less

than or equal to value

SQL_FN_HOUR(time_exp) Returns hour for time value

SQL_FN_IDENTIFIER(<value>) Formats an

SQL_IDENTIFIER value

SQL_FN_IFNULL(exp,value) Returns NULL or value

SQL_FN_INITIAL_CAPS(Value) Format value using initial

capitals

SQL_FN_INSERT(string_exp1, start, length, string_exp2) Overwrite characters in

Page 73: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

69

string

SQL_FN_LCASE(string_exp) Convert to lowercase

SQL_FN_LEFT(string_exp, count) Returns the leftmost count

of characters in string

SQL_FN_LENGTH(string_exp) Number of characters in

string less trailing blanks

SQL_FN_LOCATE(exp1,exp2[,exp3]) Returns starting position of

exp1 in exp2

SQL_FN_LTRIM(string_exp) Strip leading blanks

SQL_FN_MINUTE(time_exp) Returns minute of hour

SQL_FN_MOD(integer_exp1,integer_exp2) Returns remainder

(modulus) of integer_exp1

divided by inte2

SQL_FN_MONTH(date_exp) Returns month based on

date value

SQL_FN_MONTHNAME(date_exp) Returns name of month

SQL_FN_NEXT_MONTH_FIRST(<DateValue>) Returns the date value of

next first of month

SQL_FN_NEXT_MONTH_LAST Returns the date value of

the next month end date

SQL_FN_NEXT_WEEKDAY(<DateValue>) Returns the date value of

the next weekday

SQL_FN_NEXT_WEEKEND_DAY(<DateValue>) Returns date value of next

weekend day

SQL_FN_POWER(numeric_exp,integer_exp) Returns value raised to

power

SQL_FN_QUARTER(date_exp) Returns quarter (1-4) for

date value

SQL_FN_RAND(integer_exp) Returns random number

using value as seed

SQL_FN_REPEAT(string_exp, count) Repeat string n-times

SQL_FN_REPLACE(string_exp1,string_exp2,string_exp3) Replace all occurrences of

s2 in s1 with s3

SQL_FN_RIGHT(string_exp, count) Returns the rightmost count

of characters from string

SQL_FN_ROUND(numeric_exp,integer_exp) Returns value rounded to n-

places to right of decimal

SQL_FN_RTRIM(string_exp) Returns the characters of

string with w/o trailing

blanks

SQL_FN_SECOND(time_exp) Returns seconds for time

Page 74: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

70

value

SQL_FN_SIGN(numeric_exp) Returns -1 (neg), 0 (zero),

or 1 (positive)

SQL_FN_SOUNDEX(string_exp) Returns site-determined

value of string

SQL_FN_SPACE(count) Returns string of n-spaces

SQL_FN_SQRT(float_exp) Returns the square root of

value

SQL_FN_SUBSTRING(string_exp,start,length) Returns sub-component of

string value

SQL_FN_TIMESTAMPADD(

interval,

integer_exp,timestamp_exp)

Add interval to timestamp

SQL_FN_TIMESTAMPDIFF(

interval,

timestamp_exp1,timestamp_exp2)

Returns integer number of

intervals between m1 and

m2

SQL_FN_TIMESTAMPPART(<Part>,<TimeStamp>) Returns a specified part of a

timestamp

SQL_FN_TRUNCATE(numeric_exp,integer_exp) Truncates numeric value

SQL_FN_UCASE(string_exp) Converts all lowercase

characters to uppercase

SQL_FN_WEEK(date_exp) Returns week of year based

on date value

SQL_FN_YEAR(date_exp) Returns year of date value

LIKE Predicate

LIKE Predicate Escape Characters

The support of the LIKE predicate escape clause allows for searches to include

metacharacters. In a LIKE predicate, the underscore character (_) is used for single-

character replacement and the percent sign (%) is used for multiple-character

replacement. The percent and underscore characters can be used as literals in a LIKE

predicate by preceding them with an escape character.

The escape clause for ODBC queries looks like:

{escape ‘escape-character’}

Example

{escape ‘\’}

Example

Items

aab aac

aad aazz

aa_123 aa_245

abc ade

Page 75: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

71

SQL without escape character

select code

from item_master

where code like ‘aa_%’

Returns

aab aac

aad aazz

aa_123 aa_245

SQL with escape character

select code

from item_master

where code like ‘aa\_%’

Returns

aa_123

aa_245

Notes

• The default LIKE escape character is '\' (backslash).

• The escape character can be specified using the escape clause syntax: {escape '\'}.

• The SQL Editor supports the feature, but does not use the {} syntax.

ODBC Example

select code

from item_master

where code like ‘aa\_%’ {escape ‘\’}

SQL Editor Example

select code

from item_master

where code like ‘aa\_%’ escape ‘\’

Procedure Calls

• The KB_SQL Server API supports the use of stored procedures as a collection of

precompiled SQL statements residing on the server.

• An application can call a procedure in place of an SQL statement.

• KB_SQL supports temporary and permanent stored procedures.

• A temporary stored procedure is stored in the cache of recent SQL commands on

the server.

• A permanent stored procedure is stored as a query definition on the server.

• Stored procedures can improve performance by eliminating query compilation at

runtime.

• Permanent stored procedures can simplify application development, as most

changes to procedures are isolated on the server.

• Procedures can return a result set (1 or more columns, 1 or more rows)

• Procedures can perform DML, DCL, and DDL operations, returning no result set.

Page 76: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

72

Outer Joins

The KB_SQL Outer Join syntax is proprietary to KBS. For generic applications, use of

this syntax would compromise the portability of the application. To avoid this limitation,

generic applications use the ODBC escape clause to encapsulate the outer join syntax,

allowing the specific driver to translate into a native syntax where necessary. This is

exactly what KB_SQL does.

ODBC uses escape sequences for outer joins. The syntax of this escape sequence is as

follows:

{oj outer-join}

where outer-join is:

table-reference {LEFT | RIGHT | FULL} OUTER JOIN {table-reference | outer-join}

ON search-condition

Note that any terms in {braces} indicate that only one of the terms would appear in a

phrase. For example, an outer join would be characterized as one of LEFT, RIGHT, or

FULL.

Note also that the outer-join term can be included as part of the outer-join specification.

Although the nesting of outer joins might be a desired feature, KB_SQL does not

currently support this capability as of 10/18/2001.

B - Connection Options

Connection options

The ODBC interface allows some flexibility in the ways in which a client application can

achieve a connection to a server-based data source. The choice of option is sometimes

left to the application such as the case of Microsoft Office products. Other situations give

the developer the choice of connection strategy. These strategies are basically trading off

of several considerations, including:

• Control over appearance of dialogs in your application.

If you are building a custom application, you will want to control the dialogs that are

presented to your customers. At a minimum, his translates to using SQLConnect and

NOT using SQLDriverConnect.

• Whether or not you require a pre-configured data source to define the parameters

of the connection.

If you are building a custom application, you might want total control over the

connection parameters. You can accomplish this by controlling the creation of the data

source. You can also control this by putting the connection parameter value information

in the application code and connecting without a pre-defined data source. See File Data

Sources and DSN-less Connections.

Page 77: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

73

• When using a commercial application, your options are limited to the choices

made by the developers.

Sometimes this means that you are forced to create a certain type of connection and

certain connection strategies are not available. When evaluating a new ODBC-enabled

application, it is valuable to review the connection options that are supported.

SQLConnect

SQLConnect is the simplest connection function. It requires a data source name and

accepts an optional user ID and password. It works well for applications that hard-code a

data source name and do not require a user ID or password. It also works well for

applications that want to control their own “look and feel,” or that have no user interface.

Such applications can build a list of data sources using SQLDataSources; prompt the

user for data source, user ID, and password; and then call SQLConnect.

The SQLConnect function establishes connections to a driver and a data source. The

connection handle references storage of all information about the connection to the data

source, including status, transaction state, and error information.

It requires the following:

• A valid connection handle (hdbc).

• A valid KB_SQL username.

• A valid KB_SQL password.

Connecting from a C program.

/* Connect to data source */

rc = SQLConnect(hdbc, // hdbc is the connection handle

(SQLCHAR*) "Sales", SQL_NTS, // Sales is the DataSourceName

(SQLCHAR*) "DBA", SQL_NTS, // DBA is the username

(SQLCHAR*) "SHARK", SQL_NTS); // SHARK is the password

Connection from a M program.

S rc=$$C^SQLOS("M", "DBA", "SHARK", hdbc)

// M is the DataSourceName

// DBA is the username

// SHARK is the password

// hdbc is the connection handle

See SQLAllocConnect for information on connection handles.

Note that the values of "Sales", "DBA", and "SHARK" are used for illustrative purposes

only.

SQLDriverConnect

SQLDriverConnect is used to connect to a data source using a connection string.

SQLDriverConnect is used instead of SQLConnect for the following reasons:

Page 78: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

74

• To let the application use driver-specific connection information.

• To request that the driver prompt the user for connection information.

• To connect without specifying a data source.

SQLDriverConnect is an alternative to SQLConnect. It supports data sources that

require more connection information than the three arguments in SQLConnect, dialog

boxes to prompt the user for all connection information, and data sources that are not

defined in the system information.

SQLDriverConnect provides the following connection attributes:

• Establish a connection using a connection string that contains the data source

name, one or more user IDs, one or more passwords, and other information

required by the data source.

• Establish a connection using a partial connection string or no additional

information; in this case, the Driver Manager and the driver can each prompt the

user for connection information.

• Establish a connection to a data source that is not defined in the system

information. If the application supplies a partial connection string, the driver can

prompt the user for connection information. See DSN-Less Connections.

• Establish a connection to a data source using a connection string constructed from

the information in a .dsn file. See File Data Sources.

After a connection is established, SQLDriverConnect returns the completed connection

string. The application can use this string for subsequent connection requests. For more

information, see the Microsoft ODBC documentation.

Note that the SQLDriverConnect function is not available in the M-based interface. For

connections from M programs, use the SQLConnect function.

DSN-less Connections

If you are using ODBC 3.0 and a connection without DSN, or a file DSN, to connect to

your server, you can set the additional connection properties supported by the driver.

Connection Parameters

UID=UserName

PWD=PassWord

Driver=KB_SQL ODBC 32-bit Driver

Host=ServerAddress

TCP_PORT=ServerListeningPort

Connection Example

// DsnLessConnect.cpp

#include "stdafx.h"

#include <windows.h>

#include <sqlext.h>

int main()

{

Page 79: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

75

SQLHENV hEnv;

SQLHDBC hDbc;

SQLRETURN rc;

SQLCHAR szConnStrOut[256];

SQLCHAR szConnStrIn[] = "DRIVER=

KB_SQL ODBC 32-bit

Driver;UID=DBA;PWD=SHARK;TCP_PORT=6500;HOST=192.9.90.36;";

SQLSMALLINT cbConnStrIn, cbConnStrOut, cbConnStrOutLen;

SQLHWND hWnd = NULL;

SQLSMALLINT fDriverCompletion = SQL_DRIVER_COMPLETE_REQUIRED;

cbConnStrIn = cbConnStrOut = 256;

rc = SQLAllocEnv(&hEnv);

rc = SQLAllocConnect(hEnv, &hDbc);

rc = SQLDriverConnect(

hDbc,

hWnd,

szConnStrIn, SQL_NTS,

szConnStrOut, cbConnStrOut, &cbConnStrOutLen,

fDriverCompletion);

if (rc != SQL_SUCCESS) {

SQLCHAR szSQLState[10], szErrorMsg[128];

SQLSMALLINT cbErrorMsgMax = 128, pcbErrorMsg;

SQLINTEGER pfNativeError;

rc = SQLError(NULL,

hDbc,

NULL,

szSQLState,

&pfNativeError,

szErrorMsg, cbErrorMsgMax, &pcbErrorMsg);

}

rc = SQLDisconnect(hDbc);

rc = SQLFreeConnect(hDbc);

rc = SQLFreeEnv(hEnv);

return 0;

}

C - Error Messages

Message Format

When using the KB_SQL ODBC Driver, you may encounter errors and messages of one

type or another. It is useful to understand the format of the messages so that you can

determine the source of the error or warning. This information is also useful when

reporting errors to KBS for technical support.

Syntax

All messages have the following format:

SQLSTATE (native_error_code);[vendor_name]

Page 80: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

76

[module_name][version_number]API_function; error_message

Description

SQLSTATE SQLSTATE codes are a standard naming scheme for errors

developed by the SQL Access Group (SAG). The returned native

error code is mapped to the appropriate SQLSTATE code. If the

native error code does not have a corresponding SQLSTATE code,

the KB_SQL ODBC Driver returns SQLSTATE 37000 (Syntax error

or access violation).

Native_error_code The native error code number will be included for any error

generated by the KB_SQL Server API. It corresponds to a KB_SQL

specific error message.

Vendor_name This is the vendor name of the provider of the module that reported

the error. In the example below, it is KBS, the provider of the Server

API. It could also be Microsoft, if the module was the ODBC Driver

Manager.

Module_name This is the module responsible for the error. In the example below, it

is the KB_SQL Server API. Errors can also be tagged with KB_SQL

ODBC Driver for errors generated by the driver.

Version_number This is the version number of the module that reported the error. In

the example below, it is version 3.6

API_function This is the name of the API function that was last invoked. This

name will prefix the first error generated for a particular API

function call.

Error_message This is the native error text that corresponds to the native error code.

In the example below, the test corresponds to the error code for

#530.

Example

28000 (530): [Knowledge Based Systems, Inc.][Server API][V3.6] SQLConnect: User

name / password failure

Note: For a complete list of all the possible errors and their descriptions, see one of the

following queries: SQL_API_SQLSTATE or SQL_ERROR_LIST.

SQLCODE

Error processing typically handles the following values for SQLCODE. See also, the

SQLError function.

SQLCODE ODBC Value Description

0 SQL_SUCCESS Function completed successfully.

-1 SQL_ERROR Function failed.

-2 SQL_INVALID_HANDLE Network failure.

1. SQL_SUCCESS_WITH_INFO Function completed successfully with a

nonfatal error.

99 SQL_NEED_DATA The application needs to send parameter

Page 81: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

77

data values.

100 SQL_NO_DATA_FOUND No data found (or End-of-Data)

SQLSTATE Mappings

The following table shows the SQLSTATE codes that can be generated with diagnostic

messages from KB_SQL. See also, the SQLError function.

SQLSTATE SQLCODE Description

21000 -1 Cardinality violation.

22000 -1 Data exception.

22001 -1 String data right truncation.

22003 -1 Numeric value out of range.

22005 -1 Error in assignment.

22008 -1 Datetime field overflow.

22012 -1 Division by zero.

22026 -1 String data, length mismatch.

23000 -1 Integrity constraint violation.

24000 -1 Invalid cursor state.

25000 -1 Invalid transaction state.

26000 -1 Invalid statement name.

27000 -1 Triggered data change violation.

28000 -1 Invalid authorization specification.

33000 -1 Invalid SQLDA name.

34000 -1 Invalid cursor name.

35000 -1 Invalid condition number.

37000 -1 Dynamic SQL syntax error or access violation.

40000 -1 Rollback.

40001 -1 Serialization failure.

42000 -1 Syntax error or access violation.

44000 -1 Check option violation.

70100 -1 Operation aborted.

00000 0 Success.

01000 1. Success with information

01002 1. Disconnect error.

01004 1. Data truncated.

01006 1. Privilege not revoked.

1. S00 1. Invalid connection string attribute.

1. S01 1. Error in row.

Page 82: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

78

1. S02 1. Option value changed.

1. S03 1. No rows updated or deleted.

1. S04 1. More than one row updated or deleted.

02000 100 No data found

07000 -1 Dynamic SQL error.

07001 -1 Wrong number of parameters.

07006 -1 Restricted data type attribute violation.

08000 -1 Connection error.

08001 -1 Unable to connect to data source.

08002 -1 Connection in use.

08003 -1 Connection not open.

08004 -1 Data source rejected establishment of connection.

08007 -1 Connection failure during transaction.

08S01 -1 Communication link failure.

0A000 -1 Feature not supported.

21S01 -1 Insert value list does not match column list.

21S02 -1 Degree of derived table does not match column list.

2. A000 -1 Direct SQL syntax or access error.

2B000 -1 Dependent privileges exist.

2C000 -1 Invalid character set name.

2D000 -1 Invalid transaction termination.

3. C000 -1 Duplicate cursor name.

3D000 -1 Invalid catalog name.

3F000 -1 Invalid schema name.

HZ000 -1 Remote Database Access condition.

IM001 -1 Driver does not support this function.

IM002 -1 Data source name not found and no default driver specified.

IM003 -1 Driver specified by data source name could not be loaded.

IM004 -1 Driver's SQLAllocEnv failed.

IM005 -1 Driver's SQLAllocConnect failed.

IM006 -1 Driver's SQLSetConnectOption failed.

IM007 -1 No data source specified; dialog prohibited.

IM008 -1 Dialog failed.

IM009 -1 Unable to load translation DLL.

IM010 -1 Data source name too long.

IM011 -1 Driver name too long.

IM012 -1 DRIVER keyword syntax error.

Page 83: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

79

IM013 -1 Trace file error.

S0001 -1 Base table or view already exists.

S0002 -1 Base table not found.

S0011 -1 Index already exists.

S0012 -1 Index not found.

S0021 -1 Column already exists.

S0022 -1 Column not found.

S0023 -1 No default for column.

S1000 -1 General error.

S1001 -1 Memory allocation failure.

S1002 -1 Invalid column number.

S1003 -1 Program type out of range.

S1004 -1 SQL data type out of range.

S1008 -1 Operation canceled.

S1009 -1 Invalid argument value.

S1010 -1 Function sequence error.

S1011 -1 Operation invalid at this time.

S1012 -1 Invalid transaction operation code specified.

S1015 -1 No cursor name available.

S1090 -1 Invalid string or buffer length.

S1091 -1 Descriptor type out of range.

S1092 -1 Option type out of range.

S1093 -1 Invalid parameter number.

S1094 -1 Invalid scale value.

S1095 -1 Function type out of range.

S1096 -1 Information type out of range.

S1097 -1 Column type out of range.

S1098 -1 Scope type out of range.

S1099 -1 Nullable type out of range.

S1100 -1 Uniqueness option type out of range.

S1101 -1 Accuracy option type out of range.

S1102 -1 Table type out of range.

S1103 -1 Direction option out of range.

S1104 -1 Invalid precision value.

S1105 -1 Invalid parameter type.

S1106 -1 Fetch type out of range.

S1107 -1 Row value out of range.

S1108 -1 Concurrency option out of range.

S1109 -1 Invalid cursor position.

S1110 -1 Invalid driver completion.

S1111 -1 Invalid bookmark value.

S1C00 -1 Driver not capable.

Page 84: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

80

S1DE0 -1 No data at execution values pending.

S1T00 -1 Timeout expired

D - Info Types

SQLGetInfo

SQLGetInfo Return Values

The following table lists the information types used by ODBC along with the responses

from the KB_SQL Server. Note that items marked with an asterisk (*) are based on site-

defined names or values that could be different in your installation. This list can be

reproduced using the GetInfoAll option of the ODBC Test utility that comes with the

Microsoft ODBC SDK.

InfoType • Value

SQL_ACCESSIBLE_PROCEDURES=20 "Y"

SQL_ACCESSIBLE_TABLES=19 "Y"

SQL_ACTIVE_CONNECTIONS=0 254

SQL_ACTIVE_ENVIRONMENTS=116 254

SQL_ACTIVE_STATEMENTS=1 65534

SQL_ALTER_DOMAIN=117 0x00000000

SQL_ALTER_TABLE=86 0x00000020 = SQL_AT_ADD_COLUMN_SINGLE

SQL_ASYNC_MODE=10021 SQL_AM_NONE = 0

SQL_BATCH_ROW_COUNT=120 0x00000002 = SQL_BRC_EXPLICIT

SQL_BATCH_SUPPORT=121 0x00000000

SQL_BOOKMARK_PERSISTENCE=82 0x00000052 =

SQL_BP_DELETE | SQL_BP_UPDATE | SQL_BP_SCROLL

SQL_CATALOG_LOCATION=114 SQL_CL_START = 1

SQL_CATALOG_NAME_SEPARATOR=41 "."

SQL_CATALOG_NAME=10003 "N"

SQL_CATALOG_TERM=42 "Catalog"

SQL_CATALOG_USAGE=92 0x00000000

SQL_COLLATION_SEQ=10004 "ISO8859-1"

SQL_COLUMN_ALIAS=87 "Y"

SQL_CONCAT_NULL_BEHAVIOR=22 • SQL_CB_NULL = 0

SQL_CONVERT_BIGINT=53 0x00000000

SQL_CONVERT_BINARY=54 0x00000000

Page 85: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

81

SQL_CONVERT_BIT=55 0x00000000

SQL_CONVERT_CHAR=56 0x00000000

SQL_CONVERT_DATE=57 0x00000000

SQL_CONVERT_DECIMAL=58 0x00000000

SQL_CONVERT_DOUBLE=59 0x00000000

SQL_CONVERT_FLOAT=60 0x00000000

SQL_CONVERT_FUNCTIONS=48 0x00000000

SQL_CONVERT_INTEGER=61 0x00000000

SQL_CONVERT_INTERVAL_DAY_TIME=123 0x00000000

SQL_CONVERT_INTERVAL_YEAR_MONTH=124 0x00000000

SQL_CONVERT_LONGVARBINARY=71 0x00000000

SQL_CONVERT_LONGVARCHAR=62 0x00000000

SQL_CONVERT_NUMERIC=63 0x00000000

SQL_CONVERT_REAL=64 0x00000000

SQL_CONVERT_SMALLINT=65 0x00000000

SQL_CONVERT_TIME=66 0x00000000

SQL_CONVERT_TIMESTAMP=67 0x00000000

SQL_CONVERT_TINYINT=68 0x00000000

SQL_CONVERT_VARBINARY=69 0x00000000

SQL_CONVERT_VARCHAR=70 0x00000000

SQL_CONVERT_WCHAR=122 0x00000000

SQL_CONVERT_WLONGVARCHAR=125 0x00000000

SQL_CONVERT_WVARCHAR=126 0x00000000

SQL_CORRELATION_NAME=74 SQL_CN_ANY = 2

SQL_CREATE_ASSERTION=127 0x00000000

SQL_CREATE_CHARACTER_SET=128 0x00000000

SQL_CREATE_COLLATION=129 0x00000000

SQL_CREATE_DOMAIN=130 0x00000000

SQL_CREATE_SCHEMA=131 1. x00000001 = SQL_CS_CREATE_SCHEMA

SQL_CREATE_TABLE=132 1. x00000001 = SQL_CT_CREATE_TABLE

SQL_CREATE_TRANSLATION=133 0x00000000

SQL_CREATE_VIEW=134 1. x00000001 = SQL_CV_CREATE_VIEW

SQL_CURSOR_COMMIT_BEHAVIOR=23 SQL_CB_PRESERVE = 2

SQL_CURSOR_ROLLBACK_BEHAVIOR=24 SQL_CB_PRESERVE = 2

SQL_CURSOR_SENSITIVITY=10001 SQL_UNSPECIFIED = 0

Page 86: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

82

SQL_DATA_SOURCE_NAME=2 • "KB_SQL"

SQL_DATA_SOURCE_READ_ONLY=25 "N"

SQL_DATABASE_NAME=16 ""

SQL_DATETIME_LITERALS=119 0x00000007 = SQL_DL_SQL92_DATE | SQL_DL_SQL92_TIME |

SQL_DL_SQL92_TIMESTAMP

SQL_DBMS_NAME=17 • "KB_SQL"

SQL_DBMS_VER=18 • "04.00.mmdd"

SQL_DEFAULT_TXN_ISOLATION=26 • SQL_TXN_READ_UNCOMMITTED = 1

SQL_DESCRIBE_PARAMETER=10002 "N"

SQL_DM_VER=171 • "03.51.300213.0000"

SQL_DRIVER_HDBC=3 • 26960. x01010000

SQL_DRIVER_HDESC=135 • 1. x00000001

SQL_DRIVER_HENV=4 • 16960. x01000000

SQL_DRIVER_HLIB=76 • 1. x00FC0000

SQL_DRIVER_HSTMT=5 • 26961. x01010001

SQL_DRIVER_NAME=6 • "kbodbc32.dll"

SQL_DRIVER_ODBC_VER=77 • "03.51"

SQL_DRIVER_VER=7 • "04.00.mmdd"

SQL_DROP_ASSERTION=136 0x00000000

SQL_DROP_CHARACTER_SET=137 0x00000000

SQL_DROP_COLLATION=138 0x00000000

SQL_DROP_DOMAIN=139 0x00000000

SQL_DROP_SCHEMA=140 1. x00000001 = SQL_DS_DROP_SCHEMA

SQL_DROP_TABLE=141 1. x00000001 = SQL_DT_DROP_TABLE

SQL_DROP_TRANSLATION=142 0x00000000

Page 87: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

83

SQL_DROP_VIEW=143 1. x00000001 = SQL_DV_DROP_VIEW

SQL_DYNAMIC_CURSOR_ATTRIBUTES1=144 0x00000000

SQL_DYNAMIC_CURSOR_ATTRIBUTES2=145 0x00000000

SQL_EXPRESSIONS_IN_ORDERBY=27 "Y"

SQL_FETCH_DIRECTION=8 1. x00000001 = SQL_FD_FETCH_NEXT

SQL_FILE_USAGE=84 SQL_FILE_NOT_SUPPORTED = 0

SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1=146 1. x00000001 = SQL_CA1_NEXT

SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2=147 0x00000000

SQL_GETDATA_EXTENSIONS=81 0x0000000B = SQL_GD_ANY_COLUMN | SQL_GD_ANY_ORDER |

SQL_GD_BOUND

SQL_GROUP_BY=88 SQL_GB_GROUP_BY_CONTAINS_SELECT = 2

SQL_IDENTIFIER_CASE=28 SQL_IC_UPPER = 1

SQL_IDENTIFIER_QUOTE_CHAR=29 " "

SQL_INDEX_KEYWORDS=148 0x00000003 = SQL_IK_ASC | SQL_IK_DESC

SQL_INFO_SCHEMA_VIEWS=149 0x00000000

SQL_INTEGRITY=73 "N"

SQL_KEYSET_CURSOR_ATTRIBUTES1=150 0x00000000

SQL_KEYSET_CURSOR_ATTRIBUTES2=151 0x00000000

SQL_KEYWORDS=89 ""

SQL_LIKE_ESCAPE_CLAUSE=113 "Y"

SQL_LOCK_TYPES=78 1. x00000001 = SQL_LCK_NO_CHANGE

SQL_MAX_ASYNC_CONCURRENT_STATEMENTS=10022 0

SQL_MAX_BINARY_LITERAL_LEN=112 0

SQL_MAX_CATALOG_NAME_LEN=34 30

SQL_MAX_CHAR_LITERAL_LEN=108 200

SQL_MAX_COLUMN_NAME_LEN=30 30

SQL_MAX_COLUMNS_IN_GROUP_BY=97 0

SQL_MAX_COLUMNS_IN_INDEX=98 0

SQL_MAX_COLUMNS_IN_ORDER_BY=99 0

SQL_MAX_COLUMNS_IN_SELECT=100 0

SQL_MAX_COLUMNS_IN_TABLE=101 0

SQL_MAX_CONCURRENT_ACTIVITIES=1 65534

SQL_MAX_CURSOR_NAME_LEN=31 30

SQL_MAX_DRIVER_CONNECTIONS=0 254

SQL_MAX_IDENTIFIER_LEN=10005 30

Page 88: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

84

SQL_MAX_INDEX_SIZE=102 0

SQL_MAX_OWNER_NAME_LEN=32 30

SQL_MAX_PROCEDURE_NAME_LEN=33 35

SQL_MAX_QUALIFIER_NAME_LEN=34 30

SQL_MAX_ROW_SIZE_INCLUDES_LONG=103 "N"

SQL_MAX_ROW_SIZE=104 32767

SQL_MAX_SCHEMA_NAME_LEN=32 30

SQL_MAX_STATEMENT_LEN=105 0

SQL_MAX_TABLE_NAME_LEN=35 30

SQL_MAX_TABLES_IN_SELECT=106 0

SQL_MAX_USER_NAME_LEN=107 30

SQL_MULT_RESULT_SETS=36 "N"

SQL_MULTIPLE_ACTIVE_TXN=37 "Y"

SQL_NEED_LONG_DATA_LEN=111 "N"

SQL_NON_NULLABLE_COLUMNS=75 SQL_NNC_NON_NULL = 1

SQL_NULL_COLLATION=85 • SQL_NC_END = 4

SQL_NUMERIC_FUNCTIONS=49 0x00D35A21 = SQL_FN_NUM_ABS | SQL_FN_NUM_CEILING |

SQL_FN_NUM_FLOOR | SQL_FN_NUM_MOD | SQL_FN_NUM_SIGN |

SQL_FN_NUM_SQRT | SQL_FN_NUM_PI | SQL_FN_NUM_RAND |

SQL_FN_NUM_POWER | SQL_FN_NUM_ROUND |

SQL_FN_NUM_TRUNCATE

SQL_ODBC_API_CONFORMANCE=9 SQL_OAC_LEVEL1 = 1

SQL_ODBC_INTERFACE_CONFORMANCE=152 SQL_OIC_CORE = 1

SQL_ODBC_SAG_CLI_CONFORMANCE=12 SQL_OSCC_COMPLIANT = 1

SQL_ODBC_SQL_CONFORMANCE=15 SQL_OSC_CORE = 1

SQL_ODBC_SQL_OPT_IEF=73 "N"

SQL_ODBC_VER=10 • "03.51.0000"

SQL_OJ_CAPABILITIES=115 0x00000043 = SQL_OJ_LEFT | SQL_OJ_RIGHT |

SQL_OJ_ALL_COMPARISON_OPS

SQL_ORDER_BY_COLUMNS_IN_SELECT=90 "N"

SQL_OUTER_JOINS=38 "P"

SQL_OWNER_TERM=39 "Schema"

SQL_OWNER_USAGE=91 0x0000001F = SQL_OU_DML_STATEMENTS |

SQL_OU_PROCEDURE_INVOCATION|SQL_OU_TABLE_DEFINITION

| SQL_OU_INDEX_DEFINITION | SQL_OU_PRIVILEGE_DEFINITION

SQL_PARAM_ARRAY_ROW_COUNTS=153 SQL_PARC_BATCH = 1

SQL_PARAM_ARRAY_SELECTS=154 SQL_PAS_NO_BATCH = 2

SQL_POS_OPERATIONS=79 0x00000000

Page 89: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

85

SQL_POSITIONED_STATEMENTS=80 0x00000007 = SQL_PS_POSITIONED_DELETE |

SQL_PS_POSITIONED_UPDATE | SQL_PS_SELECT_FOR_UPDATE

SQL_PROCEDURE_TERM=40 "Procedure"

SQL_PROCEDURES=21 "Y"

SQL_QUALIFIER_LOCATION=114 SQL_CL_START = 1

SQL_QUALIFIER_NAME_SEPARATOR=41 "."

SQL_QUALIFIER_TERM=42 "Catalog"

SQL_QUALIFIER_USAGE=92 0x00000000

SQL_QUOTED_IDENTIFIER_CASE=93 SQL_IC_SENSITIVE = 3

SQL_ROW_UPDATES=11 "N"

SQL_SCHEMA_TERM=39 "Schema"

SQL_SCHEMA_USAGE=91 0x0000001F = SQL_OU_DML_STATEMENTS |

SQL_OU_PROCEDURE_INVOCATION|

SQL_OU_TABLE_DEFINITION | SQL_OU_INDEX_DEFINITION |

SQL_OU_PRIVILEGE_DEFINITION

SQL_SCROLL_CONCURRENCY=43 1. x00000001 = SQL_SCCO_READ_ONLY

SQL_SCROLL_OPTIONS=44 0x00000011 = SQL_SO_FORWARD_ONLY | SQL_SO_STATIC

SQL_SEARCH_PATTERN_ESCAPE=14 • "\"

SQL_SERVER_NAME=13 • "Server1"

SQL_SPECIAL_CHARACTERS=94 ""

SQL_SQL_CONFORMANCE=118 SQL_SC_SQL92_ENTRY = 1

SQL_SQL92_DATETIME_FUNCTIONS=155 0x00000007 = SQL_SDF_CURRENT_DATE |

SQL_SDF_CURRENT_TIME | SQL_SDF_CURRENT_TIMESTAMP

SQL_SQL92_FOREIGN_KEY_DELETE_RULE=156 0x00000000

SQL_SQL92_FOREIGN_KEY_UPDATE_RULE=157 0x00000000

SQL_SQL92_GRANT=158 0x00000C70 = SQL_SG_WITH_GRANT_OPTION |

SQL_SG_DELETE_TABLE | SQL_SG_INSERT_TABLE |

SQL_SG_SELECT_TABLE | SQL_SG_UPDATE_TABLE

SQL_SQL92_NUMERIC_VALUE_FUNCTIONS=159 0x00000000

SQL_SQL92_PREDICATES=160 0x00000E07 =

SQL_SP_EXISTS | SQL_SP_ISNOTNULL | SQL_SP_ISNULL |

SQL_SP_LIKE | SQL_SP_IN |

SQL_SP_BETWEEN

SQL_SQL92_RELATIONAL_JOIN_OPERATORS=161 0x00000140 = SQL_SRJO_LEFT_OUTER_JOIN |

SQL_SRJO_RIGHT_OUTER_JOIN

SQL_SQL92_REVOKE=162 0x00003190 = SQL_SR_GRANT_OPTION_FOR |

SQL_SR_DELETE_TABLE | SQL_SR_INSERT_TABLE |

SQL_SR_SELECT_TABLE | SQL_SR_UPDATE_TABLE

Page 90: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

86

SQL_SQL92_ROW_VALUE_CONSTRUCTOR=163 0x00000003 = SQL_SRVC_VALUE_EXPRESSION | SQL_SRVC_NULL

SQL_SQL92_STRING_FUNCTIONS=164 0x0000003E =

SQL_SSF_LOWER | SQL_SSF_UPPER | SQL_SSF_SUBSTRING |

SQL_SSF_TRANSLATE | SQL_SSF_TRIM_BOTH

SQL_SQL92_VALUE_EXPRESSIONS=165 0x00000005 = SQL_SVE_CASE | SQL_SVE_COALESCE

SQL_STANDARD_CLI_CONFORMANCE=166 2. x00000002 = SQL_SCC_ISO92_CLI

SQL_STATIC_CURSOR_ATTRIBUTES1=167 1. x00000001 = SQL_CA1_NEXT

SQL_STATIC_CURSOR_ATTRIBUTES2=168 0x00000000

SQL_STATIC_SENSITIVITY=83 0x00000000

SQL_STRING_FUNCTIONS=50 0x0007FFFF = SQL_FN_STR_CONCAT | SQL_FN_STR_INSERT |

SQL_FN_STR_LEFT | SQL_FN_STR_LTRIM | SQL_FN_STR_LENGTH |

SQL_FN_STR_LOCATE | SQL_FN_STR_LCASE |

SQL_FN_STR_REPEAT | SQL_FN_STR_REPLACE |

SQL_FN_STR_RIGHT | SQL_FN_STR_RTRIM |

SQL_FN_STR_SUBSTRING | SQL_FN_STR_UCASE |

SQL_FN_STR_ASCII | SQL_FN_STR_CHAR |

SQL_FN_STR_DIFFERENCE | SQL_FN_STR_LOCATE_2 |

SQL_FN_STR_SOUNDEX | SQL_FN_STR_SPACE

SQL_SUBQUERIES=95 0x0000001F = SQL_SQ_COMPARISON | SQL_SQ_EXISTS |

SQL_SQ_IN | SQL_SQ_QUANTIFIED |

SQL_SQ_CORRELATED_SUBQUERIES

SQL_SYSTEM_FUNCTIONS=51 0x00000007 = SQL_FN_SYS_USERNAME | SQL_FN_SYS_DBNAME |

SQL_FN_SYS_IFNULL

SQL_TABLE_TERM=45 "Table"

SQL_TIMEDATE_ADD_INTERVALS=109 0x000001FF = SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_SECOND |

SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR | SQL_FN_TSI_DAY |

SQL_FN_TSI_WEEK | SQL_FN_TSI_MONTH |

SQL_FN_TSI_QUARTER | SQL_FN_TSI_YEAR

SQL_TIMEDATE_DIFF_INTERVALS=110 0x000001FF = SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_SECOND |

SQL_FN_TSI_MINUTE | SQL_FN_TSI_HOUR | SQL_FN_TSI_DAY |

SQL_FN_TSI_WEEK | SQL_FN_TSI_MONTH |

SQL_FN_TSI_QUARTER | SQL_FN_TSI_YEAR

SQL_TIMEDATE_FUNCTIONS=52 0x0001FFFF = SQL_FN_TD_NOW | SQL_FN_TD_CURDATE |

SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK |

SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_MONTH |

SQL_FN_TD_QUARTER | SQL_FN_TD_WEEK | SQL_FN_TD_YEAR |

SQL_FN_TD_CURTIME | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE

| SQL_FN_TD_SECOND | SQL_FN_TD_TIMESTAMPADD |

SQL_FN_TD_TIMESTAMPDIFF | SQL_FN_TD_DAYNAME |

SQL_FN_TD_MONTHNAME

SQL_TXN_CAPABLE=46 SQL_TC_DML = 1

Page 91: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Appendixes

87

SQL_TXN_ISOLATION_OPTION=72 0x00000007 = SQL_TXN_READ_UNCOMMITTED |

SQL_TXN_READ_COMMITTED | SQL_TXN_REPEATABLE_READ

SQL_UNION=96 0x00000000

SQL_USER_NAME=47 • "User2"

SQL_XOPEN_CLI_YEAR=10000 "1995"

E - Data Types

Data Type Mapping

The KB_SQL Server driver maps Server datatypes to ODBC SQL datatypes. The

following table lists all Server datatypes and shows the ODBC SQL datatypes to which

they are mapped. Note that multiple Server types can map to a single ODBC type, but

each ODBC type maps to only one Server type.

ServerTypeName ServerTypeID ODBCSqlType SqlTypeName

CHARACTER 2 12 SQL_VARCHAR

DATE 5. 91 SQL_TYPE_DATE

FLAG 4 -7 SQL_BIT

ID 1. 4 SQL_INTEGER

INTEGER 3 4 SQL_INTEGER

MOMENT 8 93 SQL_TYPE_TIMESTAMP

NUMERIC 7 2. SQL_NUMERIC

TEXT 9 -1 SQL_LONGVARCHAR

TIME 6 92 SQL_TYPE_TIME

It is valuable to recognize the type names and numbers in both contexts. Working with

ServerAPI queries, either using the host-based interface or through ODBC queries, you

will see the ODBC SQLType values going back and forth.

Data Type Formats

Information is exchanged between the client application and the ODBC Driver using data

formats as defined in the C programming language. The exchange of data between the

driver and server is primarily done using character string representations of the data, with

conversions applied on either side as necessary.

It is important to realize that certain data that might appear as numbers to us in M terms

might not be a number at all in terms of a non-M application.

For example, the DATE, TIME, and MOMENT types are exchanged between the server

and driver as character strings in a particular format defined by ODBC. See the table

Page 92: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

88

below. These values are stored in the driver in a structure and provided to the application

in an application-defined format. It is important to understand that the display formatting

of the data is the responsible of the application.

Consider also the FLAG data type. Using the SQL Editor, you might be used to thinking

of FLAG types as YES/NO or TRUE/FALSE. In the exchange between the driver and

server, these values are represented as 1 (true), 0 (false), or NULL if unknown.

Depending on the application, you could see flag values displayed as -1, Yes/No, or

almost any other format applicable to a binary choice.

Character strings deserve special consideration as well. In C, a character string can be

referenced using several strategies based on the storage of character strings as a array of

character bytes. Some applications use a null-terminated-string approach, allowing

character strings to be of arbitrary length as long as they are null-terminated. Other

applications will use the defined length, as retrieved from SQLDescribeCol, to reference

the value as a fixed-length string. This can lead to errors if the actual lengths of your data

exceeds the defined length. In these cases, the driver is responsible to raise a warning

message about the truncation of the data value. The handling of this warning message is

application-dependent. There is a server-side utility, named SQLJ14, that can be used to

find data values that exceed the defined length in the data dictionary. Contact KBS

technical support if you need assistance with this important issue.

For the most part, data of the TEXT type appears to the ODBC driver as a character

string. It just happens to allow a larger maximum size. On the server side, the TEXT data

is stored in a global array of subscripted segments of character strings. The only

important point to realize is that the data has no inherent formatting. It is simply a stream

of bytes. As with the other types, the application is in control of the formatting.

See Data Type Mapping for information about how KB_SQL data types are mapped to

the ODBC types.

ServerTypeName Base Format ODBC Format

CHARACTER "hello" "hello"

DATE 57821 1999-04-23

FLAG 1. 1.

ID 123 123

INTEGER 123 123

MOMENT 57821,34557 1999-04-23 09:36:57

NUMERIC 123.45 123.45

TEXT "abcde" "abcde"

TIME 34557 09:36:57

It is valuable to recognize the data type values in both contexts. Working with ServerAPI

queries, either using the host-based interface or through ODBC queries, you will see the

ODBC format values going back and forth.

Page 93: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

89

Index

3

32-bit ODBC Drivers .......................... 3

A

AC^SQLOS ....................................... 42

Access ................... 4, 7, 8, 35, 41, 80, 81

ACCURACY ...................................... 66

Administrator ...................................... 9

AE^SQLOS ......................................... 43

Allow connections.............................. 14

AND .................................................... 41

ANSI

OEM ................................................. 5

ANSI ..................................................... 5

API

name ............................................ 80

API Function Reference ................... 41

API Function Summary ................... 38

API functions ................... 38, 41, 59, 80

API supports

DATE ............................................. 71

API supports.................................. 35, 71

API supports ...................................... 71

API_function ....................................... 80

Architecture ....................................... 35

ArrayIn ................................................ 58

ArrayOut ............................................. 58

AS^SQLOS ......................................... 43

ASCII

Returns ........................................... 72

ASCII ................................................. 72

B

Background ....................................... 22

BC^SQLOS ......................................... 44

Before you begin .................................. 9

Benefits

KB_SQL ODBC ........................... 8

Benefits of KB_SQL ODBC ................. 8

Bitmask

receive ............................................. 56

Bitmask ............................................... 56

BitString

Convert Number.............................. 56

BitString .............................................. 56

BP^SQLOS ........................................ 44

Page 94: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

90

C

C^SQLOS ........................................... 47

CA^SQLOS ........................................ 45

CARDINALITY ................................. 66

CHARACTER ................................... 91

Character set translation .................... 5

Characteristics

determine......................................... 57

Characteristics................................... 36

Characteristics ..................................... 57

CHARGES .......................................... 65

Check

SQL_ACCESSIBLE_PROCEDUR

ES ................................................ 61

Check .................................................. 61

Check .................................................. 67

Check .................................................. 81

Chr....................................................... 58

Client

Engine ............................................... 7

sets .................................................. 36

Tracing on ...................................... 26

Client ..................................................... 7

Client .................................................. 26

Client .................................................. 35

Client .................................................. 36

CM^SQLOS ................................ 46, 47

CNAME .............................................. 44

Code Page Translator

Specify ............................................ 10

Code Page Translator ....................... 10

COLTYPE........................................... 65

COLUMN .............................. 46, 47, 61

COLUMN_NAME ....................... 65, 66

ColumnName ............................... 46, 61

COMMIT ............................................ 70

Congratulations ................................. 10

Connection

SQL_ACCESS_MODE state ...... 54

Connection options............................ 76

Connection pooling ....................... 3, 31

Connection string ........................ 38, 81

Convert BitString

Number ........................................... 56

Convert BitString ................................ 56

Convert Number

BitString .......................................... 56

Page 95: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

91

Convert Number.................................. 56

Corresponding

KB_SQL ......................................... 80

SQLSTATE..................................... 80

Corresponding ..................................... 80

Create

Default Data Source .................. 10

Data Source................................ 10

Create a Default Data Source .......... 10

CS^SQLOS ......................................... 45

D

D MASK^SQLK4 ............................... 56

D SPLIT^SQLK4 .............................. 41

D UNMASK^SQLK4 ......................... 56

D WCPD^SQLK4 ............................. 68

Data Source

Give............................................. 10

create .......................................... 10

Data Source Types ............................ 25

Data Type Formats .............................. 92

Data Type Mapping .......................... 91

DATA_TYPE ..................................... 65

Date

form ............................................ 71

API supports .............................. 71

Date Time and TimeStamp .............. 71

Date value .......................................... 72

Datetime .............................................. 81

DateValue........................................... 72

DBA .................................. 36, 47, 67, 68

DBMSs ............................................... 71

DC^SQLOS ........................................ 48

Default Data Source

Create ............................................. 10

Default Data Source .......................... 10

DELETE ..................... 55, 57, 62, 64, 67

DeptEmps..................................... 36, 58

Determine

characteristics .................................. 57

Determine............................. 3, 7, 31, 48

Determine ............................................ 57

Determine ............................................ 80

Direct SQL .......................................... 81

DISCON S SQLCODE ..................... 49

DLL .......................................... 5, 35, 81

DoubleQuote ....................................... 58

Page 96: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

92

DoubleQuoted Literal ......................... 58

DP^SQLOS ......................................... 48

DRIVER .......................................... 7, 81

Driver Setup ...................................... 10

DSNless................................................. 4

DSN-less Connections ....................... 78

Dynamic SQL ..................................... 81

Dynasets .............................................. 33

E

E^SQLOS............................................ 50

ED^SQLOS ......................................... 50

Edit network configuration .............. 14

Enabling the API Trace Feature ..... 29

Enabling tracing ................................ 27

End-of-Data ....................................... 80

Engine

client .............................................. 7

Engine allocates ............................ 55, 64

Equal

99..................................................... 50

Equal ................................................... 50

Equal .................................................. 72

ER^SQLOS ....................................... 49

Error Code ................................... 49, 80

Error Processing .................................. 50

Error Text .................................... 49, 80

Escape-character ............................... 74

Excel

including........................................... 7

Return Data ................................... 34

Excel ..................................................... 7

Excel ..................................................... 7

Excel ................................................... 34

Execute

Use .................................................. 36

Execute .......................................... 35, 36

Execute ............................................... 36

Execute ............................................... 38

Execute ................................................ 43

Execute ................................................ 50

Execute ................................................ 50

Execute ................................................ 58

Execute ............................................... 61

Extensions .......................................... 71

EZQ ....................................................... 8

Page 97: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

93

F

F^SQLOS .......................................... 51

FC^SQLOS........................................ 53

FE^SQLOS ......................................... 53

File data source names........................ 4

File DSN ......................................... 4, 25

FILTER_CONDITION ....................... 66

FK^SQLOS ......................................... 51

FKOWNER ......................................... 51

FKQUAL ............................................ 51

FKTABLE........................................... 51

FkTableName ...................................... 51

FkTableOwner .................................... 51

FkTableQualifier ................................. 51

FLAG ............................................ 57, 91

Fn ........................................................ 58

Fn function .......................................... 58

Fn lcase ............................................... 58

Fn soundex .......................................... 58

Foreground .......................................... 21

Form

DATE ............................................. 71

Form .............................................. 48, 71

Form ................................................... 71

FOUND .............................................. 80

FS^SQLOS.......................................... 54

Function causes ................................. 49

Function requires ........................ 42, 43

Functions .... 7, 35, 36, 38, 41, 42, 43, 44,

45, 46, 47, 48, 49, 50, 51, 53, 54, 55,

56, 57, 58, 59, 60, 61, 62, 63, 64, 65,

66, 67, 68, 71, 72, 80, 81

G

GCN^SQLOS...................................... 55

GCO^SQLOS...................................... 54

GD^SQLOS ........................................ 55

GetExternalData ............................... 34

GI^SQLOS .......................................... 56

Give

Data Source.................................... 10

Give ....................................................... 8

Give..................................................... 10

Give..................................................... 36

GRANTEE .......................................... 67

GRANTOR ......................................... 67

GSO^SQLOS .................................... 56

GTI^SQLOS ....................................... 57

Page 98: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

94

H

HANDLE ........................................... 80

Hostname ............................................. 9

Hour

Returns minute .............................. 72

Hour ................................................... 72

How does it work? ................................ 7

Hstmt ....................................... 57, 59, 68

Hstmt containing SELECT ................. 57

I

IMPORTANT .................................... 36

Imported Tables .................................. 33

IN ........................................................ 58

Including

Excel ................................................. 7

Including .............................................. 7

INDEX_NAME .................................. 66

INDEX_QUALIFIER ......................... 66

InfoType ............................................. 84

INSERT................................... 57, 62, 67

INTEGER .......................................... 91

Internet Information Server .............. 4

Interoperability ...................................... 8

Interpreting the API Trace .................. 30

Invalid SQLDA ................................... 81

IP........................................................... 9

IS_GRANTABLE ............................... 67

ISO8859-1 .......................................... 84

J

Java....................................................... 4

K

K65 ..................................................... 49

KB Systems ....................... 56, 62, 80, 81

KB_SQL

corresponds ................................. 80

KB_SQL creates ................................ 36

KB_SQL Engine ....................... 7, 35, 46

KB_SQL ODBC

Benefits ......................................... 8

KB_SQL ODBC Driver

KB_SQL RDBMS ................................ 7

KB_SQL reserves .............................. 41

KB_SQL Server ... 7, 36, 47, 49, 80, 84,

91

KB_SQL Server API................... 36, 80

KB_SQL Server API supports ......... 36

KB_SQL Server Interface ..................... 7

Page 99: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

95

Kbodbc32.dll...................................... 84

KBSStatement ................................... 41

KEY_SEQ ..................................... 51, 60

KS^SQLOS........................................ 41

L

LENGTH............................................. 65

LIKE............................................. 71, 74

LIKE Predicate ........................... 71, 74

LIKE Predicate Escape Characters 71,

74

LinesIn ................................................ 58

LinesOut .............................................. 58

Linked Tables...................................... 33

Listening Port ...................................... 9

Literal ................................ 36, 58, 71, 74

M

M 7, 8, 41, 47, 62

M Community

mean ................................................. 7

M Community ..................................... 7

M globals .............................................. 7

M programming ................................ 41

MASK^SQLK4 ................................... 56

Maximum number of stored queries 14

Message Format .................................. 80

Meta

precede ........................................... 71

Meta .................................................... 71

Metacharacters .................................. 74

Metadata .............................................. 48

Microsoft .............. 3, 4, 7, 33, 34, 38, 80

Microsoft Access ................................ 33

Microsoft Office .............................. 4, 7

Microsoft provides The ......................... 7

Microsoft Query ................................ 34

Microsoft Transaction Server ............ 4

Module_name - This ........................... 80

MOMENT .......................................... 91

MR^SQLOS ........................................ 57

MSQuery ............................................ 36

Multiple-character ...................... 71, 74

Multi-row fetch.................................... 5

N

Name

API .................................................. 80

Name.... 5, 10, 36, 38, 41, 44, 45, 47, 48,

51, 55, 58, 60, 61, 64, 65, 66, 67, 68,

71, 72

Page 100: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

96

Name ................................................... 80

Name ................................................... 81

Name................................................... 84

Native_error_code............................... 80

Neg ...................................................... 72

Network

Specify ........................................ 10

Network Library M ............................... 7

Network TroubleShooting ................ 18

NetworkInfo....................................... 15

NON_UNIQUE................................... 66

Non-DBA ............................................ 67

NP^SQLOS........................................ 59

NPM ................................................... 59

NRC

uses ................................................. 60

NRC .................................................... 60

NRC^SQLOS .................................... 60

NS^SQLOS ......................................... 58

NULL ............................................ 48, 67

Nullable ................................... 48, 65, 81

Number

Convert BitString ............................ 56

nnn represents ............................... 36

Number ............................................ 5, 7

Number .............................................. 36

Number .............................................. 38

Number ............................................... 44

Number ............................................... 48

Number ............................................... 55

Number ............................................... 56

Number .............................................. 59

Number .............................................. 60

Number ............................................... 62

Number .............................................. 72

Number ............................................... 80

Number ............................................... 81

NUMERIC ......................................... 91

NumParams ....................................... 59

NumResultCols ............................. 48, 55

O

ODBC .. 3, 4, 5, 7, 31, 35, 36, 38, 44, 48,

56, 57, 58, 62, 71, 74, 80, 91

ODBC 3.0 ............................................. 5

ODBC Administrator ........... 3, 4, 5, 31

ODBC application ......................... 3, 31

ODBC Driver Manager ............. 7, 35, 80

Page 101: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

97

ODBC Example ................................. 74

ODBC SDK 3.51 .................................. 3

ODBC Software Development Kit ... 38

ODBC uses ......................................... 71

ODBC V1.0 ........................................ 44

ODBC Value ...................................... 80

ODBC.INI ........................................... 47

ODBC-compliant Windows

application ................................... 7, 8

ODBCSqlType ................................... 91

OEM

ANSI ................................................. 5

OEM ..................................................... 5

Open Database Connectivity .............. 7

OPTION .................................. 54, 56, 64

Overview of ADO Programming ..... 70

Overview of Windows Applications 33

Overview_M_Programming ............ 41

OWNER ... 46, 47, 60, 61, 65, 66, 67, 68

Owners ............................................... 68

P

P^SQLOS .................................... 41, 60

PAGES ................................................ 66

Parameter Markers .................. 36, 38, 48

Parameter takes ................................... 47

Parameter.Example .......................... 36

Parameters

setting ............................................. 36

Parameters ......................... 9, 10, 35, 36

Parameters ......................................... 36

Parameters ......................................... 38

Parameters ........................................... 44

Parameters ......................................... 44

Parameters ........................................... 47

Parameters ........................................... 48

Parameters ........................................... 50

Parameters ........................................... 57

Parameters ......................................... 59

Parameters ......................................... 61

Parameters ......................................... 61

Parameters ........................................... 62

Parameters ......................................... 71

Parameters ......................................... 80

Parameters ........................................... 81

Parmlist ............................................... 58

PARSEQ ............................................. 48

Part

Page 102: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

98

timestamp....................................... 72

Part ......................................... 10, 38, 41

Part ..................................................... 72

PC^SQLOS........................................ 61

PD^SQLOS ......................................... 62

PK^SQLOS ......................................... 60

PKOWNER ......................................... 51

PKQUAL ............................................ 51

PKTABLE........................................... 51

PKTABLE_NAME ............................. 51

PKTABLE_OWNER .......................... 51

PKTABLE_QUALIFIER ................... 51

PkTableName ...................................... 51

PkTableName contains ....................... 51

PkTableOwner .................................... 51

PkTableQualifier ................................. 51

PR^SQLOS........................................ 61

PRECISION .................................. 48, 65

Precompiled SQL .............................. 36

Prefix for stored query routines ...... 13

Prepare/execute ................................... 35

PRIVILEGE ........................................ 67

Procedure Calls ................................. 75

ProcName........................................... 61

ProcOwner ......................................... 61

ProcQualifier ..................................... 61

Programmer's Reference.................. 38

PSEUDO_COLUMN .......................... 65

Q

QUAL ....... 46, 47, 60, 61, 65, 66, 67, 68

R

RC^SQLOS ......................................... 62

RDBMS................................................. 8

Receive

BitMask ........................................... 56

Receive ............................................... 36

Receive ................................................ 56

Recordsets ........................................... 33

Refer

PATIENT ........................................ 51

Refer .................................................... 50

Refer .................................................... 51

Refer .................................................... 67

REFERENCES ................................... 67

REMARKS ........................................ 68

Remote Database Access .................... 81

Page 103: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

99

Respecify ............................................ 36

Result Set . 35, 36, 38, 41, 44, 46, 47, 48,

51, 55, 57, 60, 61, 62, 65, 66, 67, 68

Result set containing ........................... 51

Results

Retrieving....................................... 38

Results ........................................... 35, 36

Results ................................................ 38

Results ................................................ 41

Results ................................................. 44

Results ................................................ 46

Results ................................................ 47

Results ................................................. 48

Results ................................................. 51

Results ................................................. 54

Results ................................................. 55

Results ................................................. 57

Results ................................................. 57

Results ................................................ 60

Results ................................................. 60

Results ................................................ 61

Results ................................................ 61

Results ................................................. 62

Results ................................................. 65

Results ................................................. 66

Results ................................................. 67

Results ................................................ 68

Retrieving

Results ............................................ 38

Retrieving........................................... 38

Return Data

Excel ............................................... 34

Return Data ....................................... 34

Return Values .............................. 72, 84

Returns

ASCII ......................................... 72

Returns minute

hour ................................................ 72

Returns minute .................................. 72

Returns NULL ................................... 72

Returns seconds ................................. 72

Returns site-determined value ......... 72

Returns SQL_NO_DATA_FOUND ... 57

Returns SQL_SUCCESS .................... 57

Returns starting ................................ 72

Returns string .................................... 72

ROLLBACK ....................................... 70

Page 104: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

100

ROLLBACK commands ..................... 70

ROWS ................................................. 62

Run

WindowsNT ..................................... 9

Run ....................................................... 9

Run ..................................................... 36

Run ..................................................... 44

Run ...................................................... 54

Run ...................................................... 56

Run ..................................................... 56

Run ...................................................... 57

Run ...................................................... 63

Run ...................................................... 64

S

Safe threads ......................................... 4

SAG..................................................... 80

SC^SQLOS ......................................... 65

Scalar functions ........................... 71, 72

SCALE .......................................... 48, 65

SCN^SQLOS ..................................... 64

SCO^SQLOS ...................................... 63

SCOPE ................................................ 65

SDK

32-bit ODBC Drivers ...................... 3

SDK ...................................................... 3

Search Pattern Escape Characters .. 71

SEQ_IN_INDEX ................................ 66

Server

Tracing on .................................. 28

Server API ........................... 7, 35, 47, 80

Server datatypes ................................ 91

Server initial execute......................... 15

Server queries .................................... 36

Server user initial execute ................ 15

SERVER_nnn .................................... 36

ServerInfo .......................................... 13

ServerTypeID .................................... 91

ServerTypeName............................... 91

SET CLIENT ..................................... 36

SET PARAMETERS ........................ 36

SET STORED_PROCEDURE ........ 36

Sets ...................................................... 36

Setting

CLIENT ......................................... 36

PARAMETERS............................. 36

STORED_PROCEDURE ............. 36

Page 105: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

101

Setting................................................. 36

Shows

SQLSTATE..................................... 81

Shows .................................................. 36

Shows .................................................. 81

Shows .................................................. 91

Silent configuration options ............... 4

Single-character .......................... 71, 74

SingleQuote......................................... 58

SingleQuoted Literal ........................... 58

SM^SQLOS ........................................ 66

SoftTag ................................................ 58

Soundex......................................... 58, 72

Source-dependent ................................ 67

Specify

Code Page Translator ................... 10

Network .......................................... 10

Specify .................................................. 5

Specify ................................................ 10

Specify ................................................ 35

Specify ................................................ 36

Specify ................................................ 38

Specify ................................................ 46

Specify ................................................ 47

Specify ................................................ 51

Specify ................................................ 61

Specify ................................................ 62

Specify ................................................ 64

Specify ................................................ 71

Specify ................................................ 72

Specify ................................................ 74

Specify ................................................ 81

SPLIT^SQLK4.................................. 41

SQL.. 7, 8, 35, 36, 38, 41, 43, 48, 49, 50,

55, 57, 58, 59, 60, 61, 64, 70, 71, 72,

74, 80, 81, 91

SQL Access Group ............................. 80

SQL commands ... 38, 41, 43, 50, 58, 60

SQL COMMIT.................................... 70

SQL Data Types .......................... 35, 81

SQL datatypes ................................... 91

SQL Editor ...................................... 8, 74

SQL Editor Example ........................ 74

SQL Editor supports......................... 74

SQL SELECT .................................... 61

SQL Statement 35, 36, 38, 48, 57, 58, 59

SQL_ACCESS_MODE ................ 54, 63

Page 106: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

102

SQL_ACCESS_MODE state

connection ....................................... 54

SQL_ACCESS_MODE state .............. 54

SQL_ACCESSIBLE_PROCEDURES

check ............................................... 61

SQL_ACCESSIBLE_PROCEDURES

......................................................... 61

SQL_ACCESSIBLE_PROCEDURES

......................................................... 84

SQL_ACCESSIBLE_TABLES ....... 84

SQL_ACTIVE_CONNECTIONS ... 84

SQL_ACTIVE_ENVIRONMENTS 84

SQL_ACTIVE_STATEMENTS ...... 84

SQL_ALTER_DOMAIN .................. 84

SQL_ALTER_TABLE ..................... 84

SQL_AM_NONE .............................. 84

SQL_API_CONNECT_OPTION ....... 63

SQL_API_DATATYPE .............. 44, 57

SQL_API_INFO_OPTION................. 56

SQL_API_SQLSTATE....................... 80

SQL_API_STATEMENT_OPTION

................................................... 56, 64

SQL_ASYNC_ENABLE .................... 64

SQL_ASYNC_MODE ...................... 84

SQL_AT_ADD_COLUMN_SINGLE

......................................................... 84

SQL_ATTR_CONNECTION_POOLI

NG............................................... 3, 31

SQL_AUTOCOMMIT ....................... 63

SQL_BATCH_ROW_COUNT ........ 84

SQL_BATCH_SUPPORT ................ 84

SQL_BIND_TYPE ............................. 64

SQL_BIT................................. 57, 62, 91

SQL_BOOKMARK_PERSISTENCE

......................................................... 84

SQL_BP_DELETE ........................... 84

SQL_BP_SCROLL ........................... 84

SQL_BP_UPDATE ........................... 84

SQL_BRC_EXPLICIT ..................... 84

SQL_CA1_NEXT .............................. 84

SQL_CATALOG_LOCATION....... 84

SQL_CATALOG_NAME ................ 84

SQL_CATALOG_NAME_SEPARAT

OR................................................... 84

SQL_CATALOG_TERM ................ 84

SQL_CATALOG_USAGE............... 84

SQL_CB_NULL ................................ 84

SQL_CB_PRESERVE ...................... 84

SQL_CL_START .............................. 84

Page 107: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

103

SQL_CLOSE ...................................... 54

SQL_CN_ANY .................................. 84

SQL_COLLATION_SEQ ................ 84

SQL_COLUMN_ALIAS .................. 84

SQL_CONCAT_NULL_BEHAVIOR

......................................................... 84

SQL_CONCURRENCY ..................... 64

SQL_CONNECT_OPT_DRVR_START

......................................................... 63

SQL_CONVERT_BIGINT .............. 84

SQL_CONVERT_BINARY ............. 84

SQL_CONVERT_BIT ...................... 84

SQL_CONVERT_CHAR ................. 84

SQL_CONVERT_DATE ................. 84

SQL_CONVERT_DECIMAL ......... 84

SQL_CONVERT_DOUBLE ............ 84

SQL_CONVERT_FLOAT ............... 84

SQL_CONVERT_FUNCTIONS ..... 84

SQL_CONVERT_INTEGER .......... 84

SQL_CONVERT_INTERVAL_DAY_

TIME .............................................. 84

SQL_CONVERT_INTERVAL_YEA

R_MONTH .................................... 84

SQL_CONVERT_LONGVARBINAR

Y ...................................................... 84

SQL_CONVERT_LONGVARCHAR

......................................................... 84

SQL_CONVERT_NUMERIC ......... 84

SQL_CONVERT_REAL ................. 84

SQL_CONVERT_SMALLINT ....... 84

SQL_CONVERT_TIME .................. 84

SQL_CONVERT_TIMESTAMP .... 84

SQL_CONVERT_TINYINT ........... 84

SQL_CONVERT_VARBINARY .... 84

SQL_CONVERT_VARCHAR ........ 84

SQL_CONVERT_WCHAR ............. 84

SQL_CONVERT_WLONGVARCHA

R ...................................................... 84

SQL_CONVERT_WVARCHAR .... 84

SQL_CORRELATION_NAME ...... 84

SQL_CREATE_ASSERTION ......... 84

SQL_CREATE_CHARACTER_SET

......................................................... 84

SQL_CREATE_COLLATION ....... 84

SQL_CREATE_DOMAIN ............... 84

SQL_CREATE_SCHEMA .............. 84

SQL_CREATE_TABLE .................. 84

SQL_CREATE_TRANSLATION... 84

SQL_CREATE_VIEW ..................... 84

SQL_CS_CREATE_SCHEMA ....... 84

Page 108: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

104

SQL_CT_CREATE_TABLE ........... 84

SQL_CURRENT_QUALIFIER ......... 63

SQL_CURSOR_COMMIT_BEHAVI

OR................................................... 84

SQL_CURSOR_ROLLBACK_BEHA

VIOR .............................................. 84

SQL_CURSOR_SENSITIVITY ...... 84

SQL_CURSOR_TYPE ....................... 64

SQL_CV_CREATE_VIEW ............. 84

SQL_DATA_SOURCE_NAME ...... 84

SQL_DATA_SOURCE_READ_ONL

Y ...................................................... 84

SQL_DATABASE_NAME............... 84

SQL_DATETIME_LITERALS....... 84

SQL_DBMS_NAME ......................... 84

SQL_DBMS_VER............................. 84

SQL_DEFAULT_TXN_ISOLATION

......................................................... 84

SQL_DESCRIBE_PARAMETER .. 84

SQL_DL_SQL92_DATE .................. 84

SQL_DL_SQL92_TIME .................. 84

SQL_DL_SQL92_TIMESTAMP .... 84

SQL_DM_VER ................................. 84

SQL_DRIVER_HDBC ..................... 84

SQL_DRIVER_HDESC ................... 84

SQL_DRIVER_HENV ..................... 84

SQL_DRIVER_HLIB ....................... 84

SQL_DRIVER_HSTMT .................. 84

SQL_DRIVER_NAME..................... 84

SQL_DRIVER_ODBC_VER ........... 84

SQL_DRIVER_VER ........................ 84

SQL_DROP ........................................ 54

SQL_DROP_ASSERTION .............. 84

SQL_DROP_CHARACTER_SET .. 84

SQL_DROP_COLLATION ............. 84

SQL_DROP_DOMAIN .................... 84

SQL_DROP_SCHEMA .................... 84

SQL_DROP_TABLE ........................ 84

SQL_DROP_TRANSLATION ........ 84

SQL_DROP_VIEW .......................... 84

SQL_DS_DROP_SCHEMA............. 84

SQL_DT_DROP_TABLE ................ 84

SQL_DV_DROP_VIEW .................. 84

SQL_DYNAMIC_CURSOR_ATTRI

BUTES1 ......................................... 84

SQL_DYNAMIC_CURSOR_ATTRI

BUTES2 ......................................... 84

SQL_ERROR .................................... 80

SQL_ERROR_LIST ........................... 80

Page 109: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

105

SQL_EXPRESSIONS_IN_ORDERB

Y ...................................................... 84

SQL_FD_FETCH_NEXT ................ 84

SQL_FETCH_DIRECTION ............ 84

SQL_FILE_NOT_SUPPORTED .... 84

SQL_FILE_USAGE ......................... 84

SQL_FN_ABS ................................... 72

SQL_FN_ASCII ................................ 72

SQL_FN_CEILING .......................... 72

SQL_FN_CHAR ............................... 72

SQL_FN_CONCAT .......................... 72

SQL_FN_DAYNAME ...................... 72

SQL_FN_DAYOFMONTH ............. 72

SQL_FN_DAYOFWEEK................. 72

SQL_FN_DAYOFYEAR .................. 72

SQL_FN_DIFFERENCE ................. 72

SQL_FN_FLOOR ......................... 58, 72

SQL_FN_HOUR ............................... 72

SQL_FN_IDENTIFIER ................... 72

SQL_FN_IFNULL ............................ 72

SQL_FN_INITIAL_CAPS ............... 72

SQL_FN_INSERT ............................ 72

SQL_FN_LCASE .............................. 72

SQL_FN_LEFT ................................. 72

SQL_FN_LENGTH .......................... 72

SQL_FN_LOCATE .......................... 72

SQL_FN_LTRIM .............................. 72

SQL_FN_MINUTE ........................... 72

SQL_FN_MOD ................................. 72

SQL_FN_MONTH ............................ 72

SQL_FN_MONTHNAME ............... 72

SQL_FN_NEXT_MONTH_FIRST . 72

SQL_FN_NEXT_MONTH_LAST .. 72

SQL_FN_NEXT_WEEKDAY ......... 72

SQL_FN_NEXT_WEEKEND_DAY

......................................................... 72

SQL_FN_NUM_ABS ........................ 84

SQL_FN_NUM_CEILING .............. 84

SQL_FN_NUM_FLOOR ................. 84

SQL_FN_NUM_MOD ...................... 84

SQL_FN_NUM_PI ............................ 84

SQL_FN_NUM_POWER................. 84

SQL_FN_NUM_RAND .................... 84

SQL_FN_NUM_ROUND ................. 84

SQL_FN_NUM_SIGN ...................... 84

SQL_FN_NUM_SQRT ..................... 84

SQL_FN_NUM_TRUNCATE ......... 84

SQL_FN_POWER ............................ 72

Page 110: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

106

SQL_FN_QUARTER ....................... 72

SQL_FN_RAND ................................ 72

SQL_FN_REPEAT ........................... 72

SQL_FN_REPLACE ........................ 72

SQL_FN_RIGHT .............................. 72

SQL_FN_ROUND............................. 72

SQL_FN_RTRIM ............................. 72

SQL_FN_SECOND........................... 72

SQL_FN_SIGN ................................. 72

SQL_FN_SOUNDEX ................... 58, 72

SQL_FN_SPACE .............................. 72

SQL_FN_SQRT ................................ 72

SQL_FN_STR_ASCII ...................... 84

SQL_FN_STR_CHAR ...................... 84

SQL_FN_STR_CONCAT ................ 84

SQL_FN_STR_DIFFERENCE ....... 84

SQL_FN_STR_INSERT .................. 84

SQL_FN_STR_LCASE .................... 84

SQL_FN_STR_LEFT ....................... 84

SQL_FN_STR_LENGTH ................ 84

SQL_FN_STR_LOCATE................. 84

SQL_FN_STR_LOCATE_2............. 84

SQL_FN_STR_LTRIM .................... 84

SQL_FN_STR_REPEAT ................. 84

SQL_FN_STR_REPLACE .............. 84

SQL_FN_STR_RIGHT .................... 84

SQL_FN_STR_RTRIM .................... 84

SQL_FN_STR_SOUNDEX .............. 84

SQL_FN_STR_SPACE .................... 84

SQL_FN_STR_SUBSTRING .......... 84

SQL_FN_STR_UCASE .................... 84

SQL_FN_SUBSTRING .................... 72

SQL_FN_SYS_DBNAME ................ 84

SQL_FN_SYS_IFNULL ................... 84

SQL_FN_SYS_USERNAME ........... 84

SQL_FN_TD_CURDATE ................ 84

SQL_FN_TD_CURTIME ................ 84

SQL_FN_TD_DAYNAME ............... 84

SQL_FN_TD_DAYOFMONTH ...... 84

SQL_FN_TD_DAYOFWEEK ......... 84

SQL_FN_TD_DAYOFYEAR .......... 84

SQL_FN_TD_HOUR ........................ 84

SQL_FN_TD_MINUTE ................... 84

SQL_FN_TD_MONTH .................... 84

SQL_FN_TD_MONTHNAME ........ 84

SQL_FN_TD_NOW .......................... 84

Page 111: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

107

SQL_FN_TD_QUARTER ................ 84

SQL_FN_TD_SECOND ................... 84

SQL_FN_TD_TIMESTAMPADD .. 84

SQL_FN_TD_TIMESTAMPDIFF .. 84

SQL_FN_TD_WEEK ....................... 84

SQL_FN_TD_YEAR ........................ 84

SQL_FN_TIMESTAMPADD .......... 72

SQL_FN_TIMESTAMPDIFF ......... 72

SQL_FN_TIMESTAMPPART ........ 72

SQL_FN_TRUNCATE ..................... 72

SQL_FN_TSI_DAY .......................... 84

SQL_FN_TSI_FRAC_SECOND ..... 84

SQL_FN_TSI_HOUR ....................... 84

SQL_FN_TSI_MINUTE .................. 84

SQL_FN_TSI_MONTH ................... 84

SQL_FN_TSI_QUARTER ............... 84

SQL_FN_TSI_SECOND .................. 84

SQL_FN_TSI_WEEK ...................... 84

SQL_FN_TSI_YEAR ....................... 84

SQL_FN_UCASE .............................. 72

SQL_FN_WEEK ............................... 72

SQL_FN_YEAR ................................ 72

SQL_FORWARD_ONLY_CURSOR_

ATTRIBUTES1 ............................. 84

SQL_FORWARD_ONLY_CURSOR_

ATTRIBUTES2 ............................. 84

SQL_function ...................................... 58

SQL_FUNCTION_LIST .................. 72

SQL_FUNCTION_LIST provides .. 72

SQL_GB_GROUP_BY_CONTAINS_

SELECT ......................................... 84

SQL_GD_ANY_COLUMN .............. 84

SQL_GD_ANY_ORDER ................. 84

SQL_GD_BOUND ............................ 84

SQL_GET_BOOKMARK .................. 64

SQL_GETDATA_EXTENSIONS ... 84

SQL_GROUP_BY............................. 84

SQL_IC_SENSITIVE ....................... 84

SQL_IC_UPPER ............................... 84

SQL_IDENTIFIER ............... 68, 71, 72

SQL_IDENTIFIER_CASE .............. 84

SQL_IDENTIFIER_QUOTE_CHAR

......................................................... 84

SQL_IK_ASC .................................... 84

SQL_IK_DESC ................................. 84

SQL_INDEX_KEYWORDS ............ 84

SQL_INFO_SCHEMA_VIEWS ...... 84

SQL_INTEGER ................................ 91

SQL_INTEGRITY ............................ 84

Page 112: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

108

SQL_INVALID ................................. 80

SQL_KEYSET_CURSOR_ATTRIBU

TES1 ............................................... 84

SQL_KEYSET_CURSOR_ATTRIBU

TES2 ............................................... 84

SQL_KEYSET_SIZE ......................... 64

SQL_KEYWORDS ........................... 84

SQL_LCK_NO_CHANGE .............. 84

SQL_LIKE_ESCAPE_CLAUSE .... 84

SQL_LOCK_TYPES ........................ 84

SQL_LOGIN_TIMEOUT................... 63

SQL_LONGVARCHAR .................. 91

SQL_lower .......................................... 58

SQL_MAX_ASYNC_CONCURREN

T_STATEMENTS......................... 84

SQL_MAX_BINARY_LITERAL_LE

N ...................................................... 84

SQL_MAX_CATALOG_NAME_LE

N ...................................................... 84

SQL_MAX_CHAR_LITERAL_LEN

......................................................... 84

SQL_MAX_COLUMN_NAME_LEN

......................................................... 84

SQL_MAX_COLUMNS_IN_GROUP

_BY ................................................. 84

SQL_MAX_COLUMNS_IN_INDEX

......................................................... 84

SQL_MAX_COLUMNS_IN_ORDER

_BY ................................................. 84

SQL_MAX_COLUMNS_IN_SELEC

T ...................................................... 84

SQL_MAX_COLUMNS_IN_TABLE

......................................................... 84

SQL_MAX_CONCURRENT_ACTIV

ITIES .............................................. 84

SQL_MAX_CURSOR_NAME_LEN

......................................................... 84

SQL_MAX_DRIVER_CONNECTIO

NS ................................................... 84

SQL_MAX_IDENTIFIER_LEN ..... 84

SQL_MAX_INDEX_SIZE ............... 84

SQL_MAX_LENGTH ........................ 64

SQL_MAX_OWNER_NAME_LEN 84

SQL_MAX_PROCEDURE_NAME_L

EN ................................................... 84

SQL_MAX_QUALIFIER_NAME_LE

N ...................................................... 84

SQL_MAX_ROW_SIZE .................. 84

SQL_MAX_ROW_SIZE_INCLUDES

_LONG ........................................... 84

SQL_MAX_ROWS ............................ 64

SQL_MAX_SCHEMA_NAME_LEN

......................................................... 84

SQL_MAX_STATEMENT_LEN .... 84

SQL_MAX_TABLE_NAME_LEN . 84

Page 113: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

109

SQL_MAX_TABLES_IN_SELECT 84

SQL_MAX_USER_NAME_LEN .... 84

SQL_MULT_RESULT_SETS ......... 84

SQL_MULTIPLE_ACTIVE_TXN . 84

SQL_NC_END .................................. 84

SQL_NEED_DATA .......................... 80

SQL_NEED_LONG_DATA_LEN .. 84

SQL_NNC_NON_NULL .................. 84

SQL_NO_DATA ............................... 80

SQL_NO_NULLS .............................. 48

SQL_NON_NULLABLE_COLUMNS

......................................................... 84

SQL_NOSCAN................................... 64

SQL_NULL_COLLATION ............. 84

SQL_NULLABLE .............................. 48

SQL_NULLABLE_UNKNOWN ....... 48

SQL_NUMERIC ............................... 91

SQL_NUMERIC_FUNCTIONS ..... 84

SQL_OAC_LEVEL1 ........................ 84

SQL_ODBC_API_CONFORMANCE

......................................................... 84

SQL_ODBC_CURSORS .................... 63

SQL_ODBC_INTERFACE_CONFO

RMANCE....................................... 84

SQL_ODBC_SAG_CLI_CONFORM

ANCE ............................................. 84

SQL_ODBC_SQL_CONFORMANC

E ...................................................... 84

SQL_ODBC_SQL_OPT_IEF .......... 84

SQL_ODBC_VER............................. 84

SQL_OIC_CORE ............................. 84

SQL_OJ_ALL_COMPARISON_OPS

......................................................... 84

SQL_OJ_CAPABILITIES ............... 84

SQL_OJ_LEFT ................................. 84

SQL_OJ_RIGHT .............................. 84

SQL_OPT_TRACE ............................ 63

SQL_OPT_TRACEFILE .................... 63

SQL_ORDER_BY_COLUMNS_IN_S

ELECT ........................................... 84

SQL_OSC_CORE ............................. 84

SQL_OSCC_COMPLIANT............. 84

SQL_OU_DML_STATEMENTS .... 84

SQL_OU_INDEX_DEFINITION ... 84

SQL_OU_PRIVILEGE_DEFINITIO

N ...................................................... 84

SQL_OU_PROCEDURE_INVOCATI

ON................................................... 84

SQL_OU_PROCEDURE_INVOCATI

ON|SQL_OU_TABLE_DEFINITIO

N ...................................................... 84

Page 114: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

110

SQL_OU_TABLE_DEFINITION ... 84

SQL_OUTER_JOINS....................... 84

SQL_OWNER_TERM ..................... 84

SQL_OWNER_USAGE ................... 84

SQL_PACKET_SIZE ......................... 63

SQL_PARAM_ARRAY_ROW_COU

NTS ................................................. 84

SQL_PARAM_ARRAY_SELECTS 84

SQL_PARC_BATCH ....................... 84

SQL_PAS_NO_BATCH ................... 84

SQL_POS_OPERATIONS .............. 84

SQL_POSITIONED_STATEMENTS

......................................................... 84

SQL_PROCEDURE_TERM ........... 84

SQL_PROCEDURES ....................... 84

SQL_PS_POSITIONED_DELETE 84

SQL_PS_POSITIONED_UPDATE 84

SQL_PS_SELECT_FOR_UPDATE 84

SQL_QUALIFIER_LOCATION .... 84

SQL_QUALIFIER_NAME_SEPARA

TOR ................................................ 84

SQL_QUALIFIER_TERM .............. 84

SQL_QUALIFIER_USAGE ............ 84

SQL_QUERY_TIMEOUT ................. 64

SQL_QUIET_MODE ......................... 63

SQL_QUOTED_IDENTIFIER_CASE

......................................................... 84

SQL_RESET_PARAMS .................... 54

SQL_RETRIEVE_DATA................... 64

SQL_ROW_NUMBER....................... 64

SQL_ROW_UPDATES .................... 84

SQL_ROWSET_SIZE ........................ 64

SQL_SC_SQL92_ENTRY ............... 84

SQL_SCC_ISO92_CLI..................... 84

SQL_SCCO_READ_ONLY............. 84

SQL_SCHEMA_TERM ................... 84

SQL_SCHEMA_USAGE ................. 84

SQL_SCROLL_CONCURRENCY 84

SQL_SCROLL_OPTIONS .............. 84

SQL_SDF_CURRENT_DATE ........ 84

SQL_SDF_CURRENT_TIME ........ 84

SQL_SDF_CURRENT_TIMESTAM

P ...................................................... 84

SQL_SEARCH_PATTERN_ESCAPE

......................................................... 84

SQL_SERVER_NAME .................... 84

SQL_SG_DELETE_TABLE ........... 84

SQL_SG_INSERT_TABLE ............. 84

SQL_SG_SELECT_TABLE ............ 84

SQL_SG_UPDATE_TABLE ........... 84

Page 115: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

111

SQL_SG_WITH_GRANT_OPTION

......................................................... 84

SQL_SIMULATE_CURSOR ............. 64

SQL_SO_FORWARD_ONLY......... 84

SQL_SO_STATIC ............................ 84

SQL_SP_BETWEEN ........................ 84

SQL_SP_EXISTS .............................. 84

SQL_SP_IN ....................................... 84

SQL_SP_ISNOTNULL .................... 84

SQL_SP_ISNULL ............................. 84

SQL_SP_LIKE .................................. 84

SQL_SPECIAL_CHARACTERS ... 84

SQL_SQ_COMPARISON ............... 84

SQL_SQ_CORRELATED_SUBQUE

RIES ............................................... 84

SQL_SQ_EXISTS ............................. 84

SQL_SQ_IN ....................................... 84

SQL_SQ_QUANTIFIED .................. 84

SQL_SQL_CONFORMANCE ........ 84

SQL_SQL92_DATETIME_FUNCTI

ONS ................................................ 84

SQL_SQL92_FOREIGN_KEY_DEL

ETE_RULE ................................... 84

SQL_SQL92_FOREIGN_KEY_UPD

ATE_RULE ................................... 84

SQL_SQL92_GRANT ...................... 84

SQL_SQL92_NUMERIC_VALUE_F

UNCTIONS ................................... 84

SQL_SQL92_PREDICATES ........... 84

SQL_SQL92_RELATIONAL_JOIN_

OPERATORS ................................ 84

SQL_SQL92_REVOKE ................... 84

SQL_SQL92_ROW_VALUE_CONST

RUCTOR ....................................... 84

SQL_SQL92_STRING_FUNCTIONS

......................................................... 84

SQL_SQL92_VALUE_EXPRESSION

S ...................................................... 84

SQL_SR_DELETE_TABLE ............ 84

SQL_SR_GRANT_OPTION_FOR . 84

SQL_SR_INSERT_TABLE ............. 84

SQL_SR_SELECT_TABLE ............ 84

SQL_SR_UPDATE_TABLE ........... 84

SQL_SRJO_LEFT_OUTER_JOIN 84

SQL_SRJO_RIGHT_OUTER_JOIN

......................................................... 84

SQL_SRVC_NULL........................... 84

SQL_SRVC_VALUE_EXPRESSION

......................................................... 84

SQL_SSF_LOWER .......................... 84

SQL_SSF_SUBSTRING .................. 84

SQL_SSF_TRANSLATE ................. 84

SQL_SSF_TRIM_BOTH ................. 84

Page 116: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

112

SQL_SSF_UPPER ............................ 84

SQL_STANDARD_CLI_CONFORM

ANCE ............................................. 84

SQL_STATIC_CURSOR_ATTRIBU

TES1 ............................................... 84

SQL_STATIC_CURSOR_ATTRIBU

TES2 ............................................... 84

SQL_STATIC_SENSITIVITY ........ 84

SQL_STRING_FUNCTIONS .......... 84

SQL_SUBQUERIES ......................... 84

SQL_SUCCESS................................. 80

SQL_SVE_CASE .............................. 84

SQL_SVE_COALESCE ................... 84

SQL_SYSTEM_FUNCTIONS......... 84

SQL_TABLE_TERM ....................... 84

SQL_TC_DML .................................. 84

SQL_TEST ............................ 47, 65, 66

SQL_TIMEDATE_ADD_INTERVAL

S ...................................................... 84

SQL_TIMEDATE_DIFF_INTERVA

LS .................................................... 84

SQL_TIMEDATE_FUNCTIONS ... 84

SQL_TRANSLATE_DLL .................. 63

SQL_TRANSLATE_OPTION ........... 63

SQL_TXN_CAPABLE ..................... 84

SQL_TXN_ISOLATION ................... 63

SQL_TXN_ISOLATION_OPTION 84

SQL_TXN_READ_COMMITTED . 84

SQL_TXN_READ_UNCOMMITTED

......................................................... 84

SQL_TXN_REPEATABLE_READ 84

SQL_TYPE_DATE ........................... 91

SQL_TYPE_TIME ........................... 91

SQL_TYPE_TIMESTAMP ............. 91

SQL_UNBIND ................................... 54

SQL_UNION ..................................... 84

SQL_UNSPECIFIED ....................... 84

SQL_USE_BOOKMARKS ................ 64

SQL_USER_NAME .......................... 84

SQL_VARCHAR .............................. 91

SQL_XOPEN_CLI_YEAR .............. 84

SQLAllocConnect ....................... 42, 81

SQLAllocEnv ................................ 43, 81

SQLAllocStmt..................................... 43

SQLBindCol ....................................... 44

SQLBindParameter ....................... 36, 44

SQLCancel .......................................... 45

SQLCODE .... 41, 42, 43, 44, 45, 46, 47,

48, 49, 50, 51, 53, 54, 55, 56, 57, 58,

59, 60, 61, 62, 63, 64, 65, 66, 68, 70,

80, 81

Page 117: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

113

SQLCODE<0 Discon 41, 43, 44, 45, 47,

48, 50, 51, 54, 55, 56, 57, 60, 62, 63,

64, 65, 66, 70

SQLCODE<0 Q ................................. 49

SQLCOL ........................... 44, 45, 48, 55

SQLColAttributes ............................... 45

SQLColumnPrivileges ...................... 46

SQLColumns ..................................... 47

SQLConnect .......................... 68, 77, 80

SQLDescribeCol ........................... 45, 48

SQLDescribeParam............................. 48

SQLDisconnect .................................. 49

SQLDriverConnect ........................... 77

SQLError........................................... 49

SQLExecDirect ............................. 35, 50

SQLExecute .................................. 35, 50

SQLExtendedFetch ............................. 5

SQLFetch ........................................... 51

SQLFetchScroll ................................... 5

SQLForeignKeys ................................ 51

SQLFreeConnect............................... 53

SQLFreeEnv ....................................... 53

SQLFreeStmt ...................................... 54

SQLFreeStmt Option .......................... 54

SQLGetConnectOption ....................... 54

SQLGetCursorName ........................... 55

SQLGetData ........................................ 55

SQLGetFunctions ............................. 38

SQLGetInfo......................................... 56

SQLGetStmtOption .......................... 56

SQLGetTypeInfo ................................ 57

SQLHDBC .... 42, 43, 47, 49, 53, 54, 56,

58, 63, 70

SQLHENV ............................. 42, 43, 53

SQLHSTMT . 41, 43, 44, 45, 46, 47, 48,

49, 50, 51, 54, 55, 56, 57, 59, 60, 61,

62, 64, 65, 66, 67, 68

SQLJ10 ............................................... 56

SQLJ13............................................... 36

SQLJ20 ............................................... 67

SQLJ21 ......................................... 58, 59

SQLJ6 ................................................. 57

SQLMoreResults................................. 57

SQLNativeSql ..................................... 58

SQLNC ............................................... 49

SQLNT ............................................... 49

SQLNumParams ............................... 59

SQLNumResultCols .......................... 60

SQLParamData ................................. 38

Page 118: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

114

SQLPrepare ....................... 35, 41, 50, 60

SQLPrimaryKeys ................................ 60

SQLProcedureColumns ............. 36, 61

SQLProcedures ........................... 36, 61

SQLPutData ................................ 38, 62

SQLRowCount .............................. 57, 62

SQLSetConnectOption ................. 63, 81

SQLSetConnectOption Option ........... 63

SQLSetCursorName ......................... 64

SQLSetEnvAttr ............................. 3, 31

SQLSetParam function .................... 44

SQLSetStmtOption ............................. 64

SQLSetStmtOption Option ................. 64

SQLSpecialColumns ........................... 65

SQLSpecialColumns Column ............. 65

SQLSTATE

corresponding .............................. 80

shows........................................... 81

SQLSTATE 37000.............................. 80

SQLSTATE Mappings........................ 81

SQLStatistics ............................... 47, 66

SQLStatistics Column ......................... 66

SQLTablePrivileges ............................ 67

SQLTables ......................................... 68

SQLTables Column .......................... 68

SQLTEXT .............................. 41, 50, 60

SQLTransact ....................................... 70

SQLTransact Option ........................... 70

SQLTTYPE......................................... 70

SqlType ......................................... 48, 54

SqlTypeName .................................... 91

SQLUAUTH ....................................... 47

SQLUNAME ...................................... 47

SSO^SQLOS ....................................... 64

Starting the Server............................... 20

Statement Execution ..................... 35, 61

Stopping the Server ............................. 22

Stored Procedures ............................... 36

Stored procedures help ..................... 36

STORED_PROCEDURE

Setting............................................. 36

STORED_PROCEDURE ................. 36

String_exp1 ........................................ 72

String_exp2 ........................................ 72

String_exp3 ........................................ 72

SYSTEM TABLE.............................. 68

Page 119: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

115

System Tables .............................. 38, 68

T

T^SQLOS............................................ 70

TABLE ........... 46, 47, 60, 65, 66, 67, 68

Table Owner .............. 47, 65, 66, 67, 68

Table Qualifier .......... 47, 65, 66, 67, 68

Table Type ................................... 68, 81

TABLE_NAME ................ 60, 66, 67, 68

TABLE_OWNER ............. 60, 66, 67, 68

TABLE_QUALIFIER....... 60, 66, 67, 68

TABLE_TYPE .................................. 68

TableName ............................. 46, 60, 67

TableOwner ........................... 46, 60, 67

TableQualifier ....................... 46, 60, 67

Tables ... 7, 38, 46, 47, 51, 60, 63, 64, 65,

66, 67, 68, 71, 81, 84, 91

TCP/IP............................................. 7, 35

TCP/IP Defaults ................................ 15

TCP/IP Host Definition .................... 16

TCP/IP Port Definition ..................... 17

TEXT .................................................. 91

The KB_SQL ODBC Architecture ....... 7

TIME ............................................ 71, 91

TimeStamp

part ............................................. 72

Timestamp Data ................................ 71

Timestamp_exp1 ............................... 72

Timestamp_exp2 ............................... 72

Timestamp-literal ................................ 58

TM^SQLOS ...................................... 68

Trace API calls .................................. 14

Tracing on

Client .......................................... 26

Server ......................................... 28

Tracing on the Client ........................ 26

Tracing on the Server ....................... 28

Ts timestamp-literal ............................ 58

TTYPE ................................................ 70

TYPE ........ 44, 48, 54, 56, 57, 63, 66, 68

TYPE_NAME ..................................... 65

Types .... 8, 36, 38, 44, 45, 48, 54, 56, 57,

62, 63, 65, 68, 71, 80, 81, 91

U

Unfetched ............................................ 57

UNIQUE ............................................. 66

UNMASK ........................................... 56

UPDATE ..................... 55, 57, 62, 64, 67

Page 120: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

KB_SQL ODBC Driver Guide

116

UPDATE table-name.WHERE

CURRENT OF .......................... 55, 64

Use

Execute ........................................... 36

NRC ................................................ 60

Use ................................ 3, 4, 7, 8, 31, 36

Use ...................................................... 36

Use ...................................................... 41

Use ...................................................... 47

Use ...................................................... 48

Use ...................................................... 54

Use ...................................................... 55

Use ...................................................... 56

Use ...................................................... 56

Use ...................................................... 60

Use ...................................................... 60

Use ...................................................... 62

Use ...................................................... 63

Use ...................................................... 64

Use ...................................................... 64

Use ...................................................... 66

Use ...................................................... 68

Use ...................................................... 70

Use ...................................................... 71

Use ...................................................... 74

Use ...................................................... 81

User2................................................... 84

Using data-at-execution parameters 35

Using QUICK^SQL .......................... 23

V

V3.6 ..................................................... 80

VALUE ........... 45, 54, 55, 56, 62, 63, 64

Variable Names ................................. 41

Vendor_name - This ........................... 80

Version_number - This ....................... 80

VIEW ................................................. 68

Viewing the API Trace ..................... 29

Views ............................................ 68, 81

Visual Basic .................................... 7, 35

VMS Cluster issues ........................... 20

W

WCPD^SQLK4 ................................. 68

What is ODBC? ................................... 7

Why Program .................................... 41

Wildcards ..................................... 68, 71

Windows......................................... 7, 35

Windows programming .................... 35

Page 121: KB SQL ODBC Driver Guide - Support Home Page · The KB_SQL ODBC Driver requires TCP/IP networking software. • On your server, you need to install KB_SQL Server and you need to have

Index

117

WindowsNT

running ............................................. 9

WindowsNT ......................................... 9

WITH_INFO ..................................... 80

Word......................................... 7, 41, 71