Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Client-Library and SQL Structures [Table of Contents] Directory services

Open Client Client-Library/C Reference Manual

[-] Chapter 2 Topics
[-] Commands

Commands

In the client/server model, a server accepts commands from multiple clients and responds by returning data and other information to the clients. Open Client applications use Client-Library routines to communicate commands to servers.

Table 2-18 summarizes the Client-Library command types:

Command types

Command type

Initiated by

Summary

Language

ct_command

Defines the text of a query that the server will parse, interpret, and execute.

RPC, Package

ct_command

Specifies the name of a server procedure (Adaptive Server stored procedure or Open Server registered procedure) to be executed by the server. The procedure must already exist on the server.

Package commands are only supported by mainframe Open Server servers. They are otherwise identical to RPC commands.

Cursor

ct_cursor

Initiates one of several commands to manage a Client-Library cursor.

Dynamic SQL

ct_dynamic

Initiates a command to execute a literal SQL statement (with restrictions on statement content) or to manage a prepared dynamic SQL statement.

Message

ct_command

Initiates a message command and specifies the message-command ID number.

Send-Data

ct_command

Initiates a command to upload a large text/image column value to the server.

Sending commands

All commands are defined and sent in three steps:

  1. Initiate the command. This identifies the command type and what it executes.

  2. Define parameter values, if necessary.

  3. Send the command. ct_send writes the command symbols and data to the network. The server then reads the command, interprets it, and executes it.

Initiating a command

An application sends several types of commands to a server:

Defining parameters for a command

The following types of commands take parameters:

An application calls ct_param or ct_setparam once for each parameter a command requires. These routines perform the same function, except that ct_param copies a parameter value, while ct_setparam copies the address of a variable that contains the value. If ct_setparam is used, Client-Library reads the parameter value when the command is sent. This allows the application to change the parameter values that were specified with ct_setparam before resending the command.

Sending a command

After a command has been initiated and its parameters have been defined, an application calls ct_send to send the command to the server. The server then interprets the command, executes it, and returns the results to the client application.

Resending a command

For most command types, Client-Library allows an application to resend the command after the results of previous execution have been processed. Enhancements to ct_send, ct_cursor, and ct_bind, and the addition of ct_setparam routine in version 11.1 allow batch-processing applications to resend commands and reuse binds when repeatedly executing the same server command. This feature can eliminate redundant calls to ct_bind, ct_command, ct_cursor, and ct_param.

The application resends commands as follows:

An application can resend all types of commands except:

Deciding which type of command to use

See Chapter 5, "Choosing Command Types," in the Open Client Client-Library/C Programmer's Guide for guidance on which command type is right for your application.


SQLSTATE structure [Table of Contents] Directory services