The Open Client Embedded SQL/C Programmer’s Manual explains how to use Embedded SQL™ and the Embedded SQL precompiler with C applications. Sybase® Embedded SQL is a superset of Transact-SQL® that lets you place Transact-SQL statements in application programs written in languages such as C and COBOL.
The information in this guide is platform-independent. For platform-specific instructions on using Embedded SQL, see the Open Client/Server Programmer’s Supplement for your platform.
This guide is intended for application developers and others interested in Embedded SQL concepts and uses. To use this guide, you should:
Be familiar with the information presented in the Adaptive Server Enterprise Reference Manual
Have C programming experience
The first two chapters of this guide are introductory. If you are an experienced Embedded SQL user, you may go directly to Chapter 3, “Communicating with Adaptive Server.” The guide is organized as follows:
Chapter 1, “Introduction,” presents a brief overview of Embedded SQL and describes its advantages and capabilities.
Chapter 2, “General Information,” describes the parts of an Embedded SQL program and provides general rules for programming with Embedded SQL.
Chapter 3, “Communicating with Adaptive Server,” describes how to establish and use a communication area with SQLCA, SQLCODE, and SQLSTATE. This chapter also describes the system variables used in the communication area.
Chapter 4, “Using Variables,” explains how to declare and use host and indicator variables in Embedded SQL. This chapter also describes arrays and explains datatype conversions.
Chapter 5, “Connecting to Adaptive Server,” explains how to use Embedded SQL to connect an application program to Sybase Adaptive Server Enterprise™ and data servers, in general.
Chapter 6, “Using Transact-SQL Statements,” describes how to use Transact-SQL in an Embedded SQL application program. This chapter describes how to select rows using arrays and batches, and how to group Transact-SQL statements.
Chapter 7, “Using Dynamic SQL,” describes how to create Embedded SQL statements that your application’s users can enter interactively at runtime.
Chapter 8, “Handling Errors,” describes return codes and the Embedded SQL precompiler’s facilities for detecting and handling errors.
Chapter 9, “Improving Performance with Persistent Binding,” describes how performance might benefit from using persistent binding and how to implement it.
Chapter 10, “Embedded SQL Statements: Reference Pages,” provides reference pages for each Embedded SQL statement.
Chapter 11, “Open Client/Server Configuration File,” explains how to use the external configuration file with Embedded SQL.
Appendix A, “Precompiler Warning and Error Messages,” lists precompiler and runtime messages.
Appendix B, “Sample Code for Handling Large Text and Image Data,” contains sample programs for Embedded SQL that demonstrates the use of host variables in handling large text and image data.
The Glossary defines many of the terms used in this book.
This guide is one of several manuals you will need to have a complete understanding of Embedded SQL. Following is a list of the other manuals you may need to consult.
Sybase Adaptive Server Enterprise Reference Manual
Open Client Client-Library Reference Manual
Open Client/Server Installation Guide
Open Client Embedded SQL Reference Manual
Open Client/Server Programmer’s Supplement
Use the Sybase Getting Started CD, the Sybase Technical Library CD, and the Technical Library Product Manuals Web site to learn more about your product:
The Getting Started CD contains release bulletins and installation guides in PDF format, and may also contain other documents or updated information not included on the Technical Library CD. It is included with your software. To read or print documents on the Getting Started CD, you need Adobe Acrobat Reader (downloadable at no charge from the Adobe Web site, using a link provided on the CD).
The Technical Library CD contains product manuals and is included with your software. The DynaText reader (included on the Technical Library CD) allows you to access technical information about your product in an easy-to-use format.
Refer to the Technical Library Installation Guide in your documentation package for instructions on installing and starting the Technical Library.
The Technical Library Product Manuals Web site is an HTML version of the Technical Library CD that you can access using a standard Web browser. In addition to product manuals, you will find links to EBFs/Updates, Technical Documents, Case Management, Solved Cases, newsgroups, and the Sybase Developer Network.
To access the Technical Library Product Manuals Web site, go to Product Manuals.
Technical documentation at the Sybase Web site is updated frequently.
Finding the latest information on product certifications
Point your Web browser to Technical Documents.
Select Products from the navigation bar on the left.
Select a product name from the product list and click Go.
Select the Certification Report filter, specify a time frame, and click Go.
Click a Certification Report title to display the report.
Creating a personalized view of the Sybase Web
site (including support pages)
Set up a MySybase profile. MySybase is a free service that allows you to create a personalized view of Sybase Web pages.
Point your Web browser to Technical Documents.
Click MySybase and create a MySybase profile.
Finding the latest information on EBFs and software
updates
Point your Web browser to the Sybase Support Page.
Select EBFs/Updates. Enter user name and password information, if prompted (for existing Web accounts) or create a new account (a free service).
Select a product.
Specify a time frame and click Go.
Click the Info icon to display the EBF/Update report, or click the product description to download the software.
This section describes font style and naming conventions used in this book.
Bold type indicates words that you type in exactly as shown, for command names and keywords. For example, in the following sentence:
With execute immediate, the user can enter all or part of a Transact-SQL statement.
In all examples and syntax statements, each clause of a statement begins on a new line. Clauses that have more than one part extend to additional lines, which are indented.
Italic type indicates syntax elements that you supply. In the following example, cursor is a keyword, and cursor_name represents a user-supplied identifier:
exec sql declare cursor_name cursor for select_statement;
Embedded SQL keywords are not case sensitive. You can enter them in uppercase, lowercase, or mixed case. This guide lists Embedded SQL keywords in lowercase.
Square brackets indicate that a word or phrase is optional. In the following example, at connection_name is optional:
exec sql [at connection_name]
Ellipses (...) indicate that you can repeat the item as many times as necessary. In the following example, one or more columns and one or more host variables can be listed:
exec sql select column [, column] ... into host_variable [, host_variable] ...;
Curly braces and vertical bars indicate a choice you must make. You can choose only one item in the braces. The syntax for the whenever statement, for example, gives a choice of three conditions and four actions:
exec sql whenever {sqlerror | sqlwarning | not found} {continue | goto label | call function_name([param [, param]...]) | stop};
Each Sybase installation that has purchased a support contract has one or more designated people who are authorized to contact Sybase Technical Support. If you cannot resolve a problem using the manuals or online help, please have the designated person contact Sybase Technical Support or the Sybase subsidiary in your area.