0% found this document useful (0 votes)
187 views

Sybase

Each DB-library program has a several essential pieces Entry code a connection to the server a message handler to process message from server a callback function to exit a program. The message handler deals with message from the server to the client, or to report a problem to the client. The error handler receives errors from the server. The callback function is used to exit the program.

Uploaded by

api-19965374
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views

Sybase

Each DB-library program has a several essential pieces Entry code a connection to the server a message handler to process message from server a callback function to exit a program. The message handler deals with message from the server to the client, or to report a problem to the client. The error handler receives errors from the server. The callback function is used to exit the program.

Uploaded by

api-19965374
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

SYBASE SESSION 9-DOCUMENT

___________________________________________________________________________________________________
Copyrights Reserved Page 1 of 8
INTRODUCTION TO OPEN CLIENT PROGRAMMING

Chapter Includes:
DB-Library Programming

Essential pieces of a DB-library client

ct -Library Programming

Essential Pieces Of a ct-Library Program

ODBC

ODBC Interface

API Conformance Levels

___________________________________________________________________________________________________
Copyrights Reserved Page 2 of 8
Essential pieces of a DB-library client
Each DB-Library program has a several essential pieces
Entry code
Opening a connection to the server
A message handler to process message from server
A message handler to process message from DB-library
Exit code

Entry Code:
This is the first step to initialize the library. In the introduction C registration is
more complex with the introduction of two callback functions.
Registration of the message and error handlers can occur at any time after
calling dbinit().

Opening a connection:
After initialization has done, it’s time to open a connection server. There are
25 connections by default
Microsoft's VBSQL object can manage up to 45 separate connection from a
single object by calling sqlsetmaxprocs().
When opening a connection to a server a login record is first allocated with in
your local library.
This login records holds several pieces of information relevant to the
connection which must be set inside of your application

Two of the parameters are required

Username

Password

The message handler:

Defining a message handler is an essential part of even the smallest DB-


library applications. The message handler deals with message from the server
to the client, of in this case from sql server application.
___________________________________________________________________________________________________
Copyrights Reserved Page 3 of 8
The message handler will be fired whenever a print statement is executed by
the server or to report a problem to the client.

Using print is common inside stored procedure to pass user defined messages
back to an application.

When the message handler is invoked, several parameters are passed in to it


and the connection number the message number, the error state number, the
security level, and the message context.

Error Handler:

The error handler receives errors from DB-Library. These errors may report
that an sql server cannot be found, or the connection has been broken, or that
not enough memory is available for a connection to be opened

The error handler like the message handler is passed a number of


parameters. These parameters are the connection number causing the error,
the severity of the server, the error number, and the error description.

Exit Code:

After using the DB-library we have to shut down properly


Before exiting we have to make sure to call sqlwinExit().
It is also good practice to call sqlExit() prior calling sqlwinExit().SqlExit()
closes all open connections and frees all allocated login structures.

Ct-Library Programming:

Context:

Every ct-Lib application has a context. This context provides information


about the connection that belongs to the context.

___________________________________________________________________________________________________
Copyrights Reserved Page 4 of 8
Connections can also have properties many of which are unique to a
connection and do not relate the context.

Allocating a connection structure:

Connection structures have certain properties that can be obtained from


sybase open client client/library
The function ct_con_props() takes six parameters

Constructing a command Batch:

Once a command structure has been allocated we have to use ct_command()


to put data in to the structure.

Submitting a batch:

So to send the batch we have to call ct_send.


It takes us a single argument and a pointer to the command to the command
structure

ODBC:

ODBC allows a single application to make a standard set of calls that are then
translated through the use of an ODBC driver, into statements on the target
data base management system.
It is also possible to use SQL pass through simply to quote to the server, SQL
statements that are passed without being altered by the driver.
Open Database Connectivity (ODBC) provides a standard software API
method for using database management systems (DBMS).
The goal of ODBC is to make it possible to access any data from any
application, regardless of which database management system (DBMS) is
handling the data.

___________________________________________________________________________________________________
Copyrights Reserved Page 5 of 8
ODBC manages this by inserting a middle layer, called a database driver,
between an application and the DBMS.
The purpose of this layer is to translate the application's data queries into
commands that the DBMS understands. For this to work, both the application
and the DBMS must be ODBC-compliant -- that is, the application must be
capable of issuing ODBC commands and the DBMS must be capable of
responding to them.

JDBC-ODBC bridges:

A Jdbc-Odbc bridge consists of a Jdbc driver that employs an ODBC driver to


connect to a target database.
This driver translates JDBC method calls into ODBC function calls.
Programmers usually use such a bridge when a particular database lacks a
JDBC driver.
An ODBC-JDBC bridge consists of an Odbc driver, which uses the services of a
Jdbc driver to connect to a database.

ODBC Interface:

ODBC (Open Database Connectivity) is a standardized API that can be used to


access data stored in various database management systems (DBMSs).
It provides a product-neutral interface between front-end applications and
database servers, enabling a developer to write applications that are
transportable between database servers from different vendors.
The Microsoft Open Database Connectivity (ODBC) interface is a C
programming language interface that makes it possible for applications to
access data from a variety of database management systems (DBMSs). ODBC
is a low-level, high-performance interface that is designed specifically for
relational data stores.
The ODBC interface allows maximum interoperability—an application can
access data in diverse DBMSs through a single interface. Moreover, that
___________________________________________________________________________________________________
Copyrights Reserved Page 6 of 8
application will be independent of any DBMS from which it accesses data.
Users of the application can add software components called drivers, which
interface between an application and a specific DBMS.

ODBC Conformance Levels:


ODBC defines two different conformance standards for drivers:

API conformance standard


SQL conformance standard
Each conformance standard is made up of three levels. These levels help
application and driver developers establish standard sets of functionality.

API Conformance Levels:


The API conformance standard is made up of three levels:

Core API

Level 1 API

Level 2 API

Core API: A set of core functions that correspond to the functions in the X/Open
SQL Access Group Call Level Interface specification.

Level 1 API: Core API functionality plus all Level 1 functionality.

Level 2 API: Core and Level 1 API functionality plus all Level 2 functionality.

ODBC API Functions:

The Connect ODBC drivers support all Core and Level 1 functions. In addition,
each driver supports a key set of the Level 2 functions. For a list of supported
Level 2 functions by driver, refer to the "ODBC Conformance Levels" section for
the database you are connecting to in the Connect ODBC Reference.

___________________________________________________________________________________________________
Copyrights Reserved Page 7 of 8
1) What are the essential pieces of a DB-Library client?

2) Explain the essential pieces of a ct-Library Program

3) How do you construct a batch and submit a batch?

4) How do you allocate a


Context structure.
Connection Structure.
Command structure.

5) What are the conformance levels in API?

6) By using VB how will you build a sample odbc application?

7)What is ODBC? Explain ODBC interface

8)How do you retrieve Object information?

Topics Covered:

DB Library programming

CT -Library Programming

Book for Reference

Book: Sybase SQL Server 11

by

Ray Rankins

Jeffrey R. Garbus

David Solomon

___________________________________________________________________________________________________
Copyrights Reserved Page 8 of 8

You might also like