The Open Client Embedded SQL/COBOL Programmer’s Manual explains how to use Embedded SQL™ and the Embedded SQL precompiler with COBOL applications. Embedded SQL is a superset of Transact-SQL® that lets you place Transact-SQL statements in application programs written in languages such as COBOL and C.
The information in this guide is platform-independent. For platform-specific instructions on using Embedded SQL, see the Open Client/Server Programmer’s Supplement.
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 in the SQL Server Reference Manual
Have COBOL 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 SQL Server.” The manual 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 tasks 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® SQL Server® or 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, “Embedded SQL Statements: Reference Pages,” provides a reference page for each Embedded SQL statement.
Chapter 10, “Open Client/Server Configuration File,” describes the use of an external configuration file with Embedded SQL.
Appendix A, “Precompiler Warning and Error Messages,” lists precompiler and runtime messages.
The Glossary defines many of the terms used in this manual.
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 keywords and command names that you type exactly as they appear in the text, as in the following sentence:
You can also include update and delete where current of cursor statements
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.
Monospace type indicates keywords you enter exactly as shown. For example:
exec sql init;
Italictype 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 end-exec
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.
This distinguishes Embedded SQL statements from COBOL commands, which this guide shows in upper case. For example:
DISPLAY "PLEASE ENTER USER-ID".
Square brackets indicate that a word or phrase is optional. In the following example, at connection_name is optional:
exec sql [at connection_name]
An ellipsis (...) indicates that you can repeat the item that precedes it 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] ... end-exec
Curly braces and vertical bars indicate a choice you must make. You can choose only one option. The syntax for the whenever statement, for example, gives a choice of three conditions and five actions:
exec sql whenever {sqlerror | sqlwarning | not found} {continue | goto label | call function_name([param [, param]...]) | perform para_name [through para_name] | stop}
If you have access to SQL Server release 10.0 or later, you can use sp_syntax, a system procedure, to retrieve the syntax of Embedded SQL statements. For information on how to install sp_syntax, see the System Administration Guide. For information on how to run sp_syntax, see sp_syntax in the SQL Server Reference Manual.
When using sp_syntax to
retrieve a statement’s syntax, enclose the procedure name
in quotation marks. For example, to get a display of the syntax for
the exec sql statement, enter this command:
sp_syntax “exec
sql”
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.