CT-Library Samples

Correction to the book reference and the updated sample list in Open Client and Open Server Programmers Supplement for UNIX.

The book reference is documented as Installation Guide Adaptive Server Enterprise 15.7 in Open Client and Open Server Programmers Supplement for UNIX > Open Client Client-Library/C > Using Client-Library sample programs. However, the correct book reference is Installation Guide Adaptive Server Enterprise 15.7 for [Sun Solaris|Linux|IBM AIX|HP-UX].

Description for these header files are missing from the Open Client and Open Server Programmers Supplement for UNIX:

Sample Header File Description
ctxact.h This file contains header files for the two phase commit functions in ctxact.c.
example.h This is the header file that goes with the Client-Library example programs.
exasync.h This is the header file which defines constants and data structures which are used in the async example program.
exutils.h Header file which contains the defines and prototypes for the utility functions in exutils.c and exutils2.c.
thrdfuc.h Header file which contains the defines and prototypes for the utility functions in thrdfunc.c.
thrdutil.h Header file which contains the defines and prototypes for the utility functions in thrdutil.c.
wide_example.h This is the header file that goes with the Client-Library example programs. It is used in wide_*.c programs.
These CT-Library sample program files are missing from the Open Client and Open Server Programmers Supplement for UNIX:
CT-Library Sample Program Files Description
csr_disp_scrollcurs3.c

This example demonstrates using a scrollable, read-only cursor. This cursor also used RELLOCKS_ON_CLOSE to instruct ASE to close a read-only cursor that uses shared level 1 locks.

It opens a cursor with a canned query. It processes the results using the standard ct_results() while loop. It binds the column values to program variables. It then fetches and displays the rows in the standard ct_scroll_fetch() loop.

This example uses a single prefetch buffer (CS_CURSOR_ROWS = 1) and regular program variables. See the csr_disp_scrollcurs2 example for a scrollable cursor with a user-defined array and array binding.

dynamic.c

This program uses Dynamic SQL to retrieve values from the titles table in the tempdb database.

The select statement, which contains placeholders with identifiers, is sent to the server to be partially compiled and stored. Therefore, every time when select is called, new values are passed for the key value, which determines the row to be retrieved. The behavior is similar to passing input parameters to stored procedures.

exutils2.c

This example file contains utility routines which are used only by the scrollable cursor sample programs. This file is used with the csr_disp_scrollable and csr_disp_scrollable2 examples. It uses an array of index values to simulate a user driving the ct_scroll_fetch() API. The values are chosen by passing a numerical list (sequence of valid integers) to generate a pattern of commands retrieving random data off a read-only scrollable cursor.

The csr_disp_scrollable example uses a section out of this file based on program variables only, prefetch count is set to 1. The csr_disp_scrollable2 example uses arrays plus array binding. These examples are illustrative.

id_update.c

This is the example program that demonstrates the use of identity_update option. It connects to a server, creates test_table in the pubs2 database, inserts a couple of rows with an identity field, then turns on the identity_update option and updates the identity in one of the rows with a user-specified value.

lobdynamic.c

This example demonstrates how to send CS_TEXT_TYPE and CS_IMAGE_TYPE parameters in chunks in a dynamic SQL statement to a server.

This sample can be run against ASE 15.7 or later version, or against Open Server sample paramreader. The sample creates a table LOBtable, insert two rows into the table and the use a dynamic select statement to run a couple of queries on the table.

lobrpc.c

This example program demonstrates sending a RPC command to a server containing a mixture of (LOB) parameters.

The example uses standard ANSI C for input/output and memory management. All work is performed synchronously.

locator.c

This example program demonstrates the use of LOB locators.

A lob locator value is retrieved from the server, including some pre-fetch data from the entire LOB value in the server. Operations on the LOB in the server are being performed using the retrieved locator value.

thrdutil.c

This example file contains utility routines which are used by multithreaded sample program.

It demonstrates how an application can hide some of the implementation details of CT-Lib from higher level programs.

uctext.c

This example program how to perform partial text updates. The text is retrieved from an ASE. ASE doesn't support.

The text is retrieved from an ASE. ASE doesn't supports partial updates of text so, a request is sent to an Open Server that does not support it.

The Open Server program provides the server part of the example. In a more realistic scenario, the Open Server sends the updatetext (partial update) command to a server that does support the functionality (for example, MSSQL). In this sample, the Open Server sends a message back to the client indicating the text received. The example uses standard ANSI C library routines for input/output and memory management. All work is performed synchronously.