Sample programs

The following sample programs and header files are installed with Client-Library. Each file contains a header describing the file’s contents and purpose. See the readme file for a complete description of each sample program.

Sample program

Description

arraybind.c

Demonstrates use of array binding in conjunction with a CS_LANG_CMD initiated by ct_command.

blktxt.c

Uses the bulk copy routines to copy static data to a table.

compute.c

Shows how to send a Transact-SQL command and process compute and regular results.

csr_disp.c

Demonstrates the use of a read-only cursor.

csr_disp_ implicit.c

Uses a scrollable cursor to retrieve data from the author table in pubs2 database. Also uses a single pre-fetch buffer and regular program variables.

csr_disp_ scrollcurs.c

Uses a scrollable cursor to retrieve data from the author table in pubs2 database. Also uses a single pre-fetch buffer and regular program variables.

csr_disp_ scrollcurs2.c

Uses a scrollable cursor with arrays as program variables; array binding is used. A single ct_scroll_fetch call displays results in an array.

ctexact.c

A two-phase commit sample program.

ctpr.c

Provides maximum printing lengths for fixed-length data.

ex_alib.c ex_amain.c

A collection of routines that form an example of how to write an asynchronous layer on top of Client-Library.

example.h

A header file for the Client-Library sample programs.

exasync.h

Sends a language command and processes the results asynchronously. A header file for the constants and data structures in ex_alib.c and ex_amain.c.

exconfig.c

Shows how to set CS_SERVERNAME property value through the default external configuration file: $SYBASE/$SYBASE_OCS/config/ocs.cfg.

exutils.c

Contains utility routines used by all of the other sample programs, and demonstrates how an application can hide some of the implementation details of Client-Library from higher-level programs.

exutils2.c

Contains utility routines used by scrollable cursor sample programs. Used with the csr_disp_scrollable and csr_disp_scrollable2 examples.

exutils.h

A header file for the utility functions in exutils.c and exutils2.c.

firstapp.c

Connects to a server, sends a select query, and prints the rows.

getsend.c

Shows how to retrieve and update text data.

id_update.c

Demonstrates use of identity_update option.

i18n.c

Demonstrates some of the international features available in Client-Library.

multithrd.c

With thrdfunc.c, demonstrates techniques for coding a multithreaded client application with Client-Library.

NoteThis sample is coded for use with Solaris native threads package, and DCE pthread APIs.

rpc.c

Illustrates sending an RPC command to a server and then processing the row, parameter, and status results returned from the remote procedure.

secct.c

Demonstrates how to use network-based security features in a Client-Library application. To use the program, DCE or CyberSafe Kerberos must be installed and running, and you must connect to a server that supports network-based security.

secct_dec secct_krb

Demonstrates how to use networked-based security with DCE or CyberSafe Kerberos.

thrdfunc.c

With multithrd.c, demonstrates techniques for coding a multithreaded client application with Client-Library.

thrdutil.c

Contains utility routines used by multithreaded sample programs. Demonstrates how applications can hide implementation details of Client-Library from higher level programs.

twophase.c

A two-phase commit sample program that performs a simple update on two different servers. Once you run the example, use isql on each server to determine whether the update took place.

uni_blktxt.c

Uses the bulk-copy routines to copy static data to a server table.

uni_compute.c

Demonstrates processing compute results. It is a modification of compute.c.

uni_csr_disp.c

Demonstrates using a read-only cursor. It is a modification of uni_csr_disp.c and requires the unipubs database.

uni_firstapp.c

Modification of firstapp.c for use with unichar and univarchar datatypes, and is an introductory example that connects to the server, sends a select query, and prints the rows.

uni_rpc.c

Sends an RPC command to a server and processes the results. This is a modification of rpc.c for use with unichar and univarchar datatypes, and requires the unipubs database.

usedir.c

Illustrates searching for servers that are available to connect to.

wide_compute.c

Demonstrates processing compute results with wide tables and larger column sizes.

wide_curupd.c,

wide_ dynamic.c

Uses a cursor to retrieve data from the publishers table in the pubs2 database.

wide_rpc.c

Sends an RPC command to a server and processes the results. Same as wide_rpc.c, but uses wide tables and larger column sizes.

wide_util.c

Contains generic routines used by the wide_* sample programs. They include init_db, cleanup_db, connect_db, handle_returns and fetch_n_print.

Before building and running an example, you must make sure the server and the client application environment are set up properly. In addition, you may want to change the user name with which the example is connecting to the server. For instructions, see the Open Client and Open Server Programmers Supplement for Microsoft Windows or Open Client and Open Server Programmers Supplement for UNIX.