Sybase Business Intelligence Solutions - Database Management, Data Warehousing Software, Mobile Enterprise Applications and Messaging
Sybase Brand Color Bar
delete

Search for    in all of Sybase.com
view all search results right arrow
  blank
 
 
 
 
 
 
 
 
 
 
Downloads > Code Samples & Utilities > Sample Programs for the DB-Library to Client-Libra...

Sample Programs for the DB-Library to Client-Library Migration Guide

These sample programs accompany the DB-Library to Client-Library Migration Guide.
 
RSS Feed
 
 
 

Summary

This download contains the sample programs to accompany the DB-Library to Client-Library Migration Guide. The programs are Client-Library versions of the DB-Library sample programs shipped with the product.

Contents

This TechNote contains the following sections:

Disclaimer

Important: Read this disclaimer before using the enclosed code:

THIS CODE IS BEING DISTRIBUTED FREE OF CHARGE. IT IS NOT A SYBASE PRODUCT, IS NOT SUPPORTED BY SYBASE AND IS PROVIDED “AS-IS” WITHOUT WARRANTY OF ANY KIND. SYBASE DISCLAIMS ALL WARRANTIES OR CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, MERCHANTABLE QUALITY, NONINFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE (WHETHER ARISING BY STATUTE OR IN LAW OR AS A RESULT OF A COURSE OF DEALING OR USAGE OF TRADE). IN NO EVENT SHALL SYBASE BE LIABLE FOR LOSS OF PROFITS OR LOSS OF DATA OR ANY DAMAGES WHATSOEVER INCLUDING WITHOUT LIMITATION DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL OR SPECIAL DAMAGES, EVEN IF SYBASE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Download the Samples

The download contains all the program, header, and datafiles, as well as a sample makefile for Unix platforms. Create a directory for the samples and associated files, and download the compressed file for your platform:

Expand the download using the WinZip or tar utility.

Build Instructions

To make these sample programs, you must install the Client-Library sample programs shipped with the product. Typically, these files are installed as part of the Open Client/ C Developer’s kit on all supported platforms. These sample program files can be found in one of the following directories, depending on the product version:

  • 11.x: SYBASE/sample/ctlibrary

  • 12.0: SYBASE/OCS-12_0/sample/ctlibrary

  • 12.5: SYBASE/OCS-12_5/sample/ctlibrary

The sample directory includes a makefile and README. Use the makefile as a guide to build the samples below. See the README for the environment variables to set. The Client-Library samples directory also contains exutils.c, a file required to build some of the samples below.

The migration samples in this download do not include DB-Library versions of the converted examples (except for dbfirst.c). The migration samples are conversions of the DB-Library product samples. If you have the Open Client/C Developer’s kit, you will also find the DB-Library samples shipped as part of the product.

List of Programs

The following programs are included in this download:

  • ctfirst — A simple example that initializes Client-Library, connects to a server, and raises deliberate errors to demonstrate the callback error handlers. The dbfirst sample program does the same thing in DB-Library.

  • dbfirst — A simple DB-Library example that initializes DB-Library, connects to a server, and raises a deliberate error. The ctfirst sample program does the same thing in Client-Library. This code is provided only for comparison to ctfirst.

  • ex01ct — DB-Library’s example1 converted to Client-Library. Illustrates conversion of code that does 2 selects and uses the dbcurcmd() and dbcurrow() functions.

  • ex02ct — DB-Library’s example2 converted to Client-Library. Illustrates conversion of code which creates a table and selects from it. Shows binding for a wide variety of datatypes

    This program requires that the file datafile be in the working directory. This file provides data to populate the created table.

  • ex03ct — DB-Library’s example3 converted to Client-Library. Illustrates conversion of code which sends a select language command and handles regular and compute rows.



    Note:

    The Client-Library compute sample program demonstrates a more robust and modular implementation of similar processing.


  • ex04ct — DB-Library’s example4 converted to Client-Library. Illustrates how Client-Library’s array binding offers similar functionality to DB-Library row buffering.

    This sample program uses the routines in ctrowbuf.c. These routines use Client-Library array binding to create and manage a row buffer.

  • ex05ct — DB-Library’s example5 converted to Client-Library. Illustrates conversion of dbconvert() and dbdatename() calls.

    This sample program uses the dbct_datename() function from the dbctutil.c sample utility library.

  • ex06ct — DB-Library’s example6 converted to Client-Library. Illustrates conversion of DB-Library browse-mode updates to Client-Library cursor updates. Creates an “alltypes” table, inserts rows to it, then uses a cursor to increment the “age” column in each row.

    This program requires that the file datafile be in the working directory. This file provides data to populate the created table.

    As a bonus sideshow, this program includes code that shows how simultaneous commands can be executed on one connection using a Client-Library cursor. To enable compilation of this code, make sure SIDESHOW is defined on the compiler command line for ex06ct

  • ex08ct — DB-Library’s example8 converted to Client-Library. Illustrates conversion of code that sends an RPC command. Also illustrates conversion of code that handles regular row results and output parameter results.

    This program expects the rpctest stored procedure to exist in pubs2, and that the user has execute permission for it. The rpctest.sql isql script creates the procedure in pubs2.



    Note:

    The Client-Library rpc sample program demonstrates a more robust and modular implementation of similar processing.


  • ex09ct — DB-Library’s example9 converted to Client-Library. Illustrates conversion of a dbwritetext() call (used without dbmoretext()).

    This sample program uses the txtimg utility routines.

  • ex10ct — DB-Library’s example10.c converted to Client-Library. Illustrates conversion of code that used dbwritetext() and dbmoretext() to send text and image values.

    This sample program uses the txtimg utility routines.

  • ex11ct — DB-Library’s example11 converted to Client-Library. Illustrates conversion of code that selects a large-value text/image column and writes the value to an operating system file.

List of Source Files

In addition to the sample program files (<program_name>.c), the following source files are included in this download:

  • dbctutil.c — Contains utility routines useful for converting DB-Library code

  • dbctutil.h — Header file containing prototypes for the dbctutil routines.

  • ctrowbuf.c — Utility routines for using Client-Library’s array binding feature.

  • ctrowbuf.h — Header for ctrowbuf routines.

  • testctrb.c — Simple program used to test the ctrowbuf routines. (essentially a simplified isql).

  • txtimg.c — Useful utility routines for updating text/image values with Client-Library.

  • txtimg.h — Header for txtimg.c

  • datafile — A text-format input file required by ex02ct and ex06ct

  • imagefile — A data file for the ex10ct sample program.

  • rpctest.sql — SQL Script that creates the stored procedure required by example8 and ex08ct. If you use this to set up for the DB-Library example8 program, you need to make sure that the user login used by example8 has pubs2 as the default database.

  • makefile — The make file for the sample programs.

  • ms.mak — Microsoft makefile for MS Visual C++. Makes Windows quickwin executables.

  • dbtoctex.def — Link segment definition file for making the migration sample programs on Windows.


 

Related Links

DOCUMENT ATTRIBUTES
Last Revised: Jan 08, 2002
Product: Open Client
Technical Topics: Migration, Middleware, Connectivity, Install/Upgrade, Application Development
  
Business or Technical: Technical
Content Id: 1013159
Infotype: Download
 
 
 

© Copyright 2014, Sybase Inc. - v 7.6 Home / Contact Us / Help / Jobs / Legal / Privacy / Code of Ethics