#EDIR DATA#
DOCTYPE='BOOK' PUBLICID='-//SYBOOKS//Default DTD//EN' SYSTEMID=''DOCTYPE='book' PUBLICID='' SYSTEMID=''Open Client Embedded SQL/C Programmer's GuideOpen Client Embedded SQL/C Programmer's GuideREMAP="titleBO--Body"SYBASE Embedded SQL Release 10.0REMAP="titleBO--Body"Document ID: 35610-00-1000-03REMAP="titleBO--Body"Change Level: 1REMAP="titleBO--Body"Last Revised: January 15, 1994Principal authorship: Winnifred GilmoreContributing authorship: Chris Black, Dave Clegg, Sanjay Dayal, Ed Fourt, Steve Goodman, Jeff Richey, Gerry Smith, Pegler SwiftDocument ID: 35610-00-1000REMAP="discBO--Body"This publication pertains to SYBASE Embedded SQL Release 10.0 of the SYBASE database management software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of the agreement.Document OrdersREMAP="discBO--Body"Customers may purchase additional copies of any document or the right to make photocopies of documentation for their in-house use.REMAP="discBO--Body"To order additional documents or photocopy rights, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.REMAP="discBO--Body"Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the fax number. All other international customers should contact their Sybase subsidiary or local distributor.REMAP="discBO--Body"Upgrades are provided only at regularly scheduled software release dates.REMAP="discBO--Body"© Copyright Sybase, Inc., 1989, 1994. All rights reserved.REMAP="discBO--Body"No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical or otherwise, without prior written permission of Sybase, Inc.REMAP="discBO--Body"Sybase TrademarksREMAP="discBO--Body"SYBASE, the SYBASE logo, SyBooks, APT-FORMS, Data Workbench, DBA Companion, Deft, GainMomentum, SA Companion, SQL Debug, SQL Solutions, SQR, Transact-SQL, and VQL are registered trademarks of Sybase, Inc. ADA Workbench, Adaptable Windowing Environment, Application Manager, Applications from Models, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-Translator, APT-Library, Build Momentum, Camelot, Client/Server Architecture for the Online Enterprise, Client/Server for the Real World, Configurator, DataServer, Data Workbench, Database Analyzer, DB-Library, Deft Analyst, Deft Designer, Deft Educational, Deft Professional, Deft Trial, Developers Workbench, Easy SQR, Embedded SQL, Enterprise Builder, Enterprise Client/Server, Enterprise Meta Server, Enterprise Modeler, Enterprise Momentum, Gain, GainExposure, Insight, Mainframe Access Products (MAP), Momentum, Movedb, Navigation Server, Net-Gateway, Net Library, Object Momentum, OmniSQL Gateway, Omni SQL Server, OmniSQL Access Module, Open Client, Open Gateway, Open Server, Open Solutions, PC APT-Execute, PC DB-Net, PC Net Library, Report Workbench, Report Execute, Open Server, Partnerships that Work, Replication Server, Resource Manager, RW-Display Lib, RW-Library, SA Monitor, Secure SQL Server, Secure SQL Toolset, SQL Code Checker, SQL Edit/TPU, SQL Edit, SQL Monitor, SQL Server, SQL Toolset, SQL Server/CFT, SQL Server/DBM, SQL Station, SQR Toolset, SQR Developers Kit, SQR Workbench, SYBASE Client/Server Interfaces, SYBASE Gateways, SYBASE SQL Lifecycle, Sybase Synergy Program, SYBASE Virtual Server Architecture, SYBASE User Workbench System 10, Tabular Data Stream, and The Enterprise Client/Server Company are trademarks of Sybase, Inc.REMAP="discBO--Body"All other company and product names used herein may be the trademarks or registered trademarks of their respective companies.Restricted Rights LegendREMAP="discBO--Body"Use, duplication or disclosure by the Government is subject to restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies.REMAP="discBO--Body"Sybase, Inc., 6475 Christie Avenue, Emeryville, CA 94608REMAP="discBO--Body"PrefaceREMAP="BO--Body"The Open Client Embedded SQL/C Programmer's Guide explains how to use Embedded SQL and the Embedded SQL precompiler with C applications. SYBASE Embedded SQLname='trade' font='symbol' code='228'  charset='fontspecific' is a superset of Transact-SQLname='trade' font='symbol' code='228'  charset='fontspecific' that lets you place Transact-SQL statements in application programs written in languages such as C and COBOL. REMAP="BO--Body"The information in this guide is platform-independent. For platform-specific instructions on using Embedded SQL, see the SYBASE Open Client/Server Supplement for your platform. RENDERAS="SECT1"AudienceREMAP="BO--Body"This guide is intended for application developers and others interested in Embedded SQL concepts and uses. To use this guide, you should: MARK="BULL" REMAP="BU--Bullet"Be familiar with the information presented in the SQL Server Reference ManualHave C programming experienceRENDERAS="SECT1"How to Use this BookREMAP="BO--Body"The Open Client Embedded SQL/C Programmer's Guide has eight chapters and four appendixes. The first two chapters are introductory. If you are an experienced Embedded SQL user, you may go directly to LINKEND="X69910"Chapter 3,  "Communicating with SQL Server"
. The guide is organized as follows:MARK="DASH" REMAP="BS--BulletSub"LINKEND="X26480"Chapter 1,  "Introduction,"
 presents a brief overview of Embedded SQL and describes its advantages and capabilities. LINKEND="X56073"Chapter 2,  "General Information,"
 describes the parts of an Embedded SQL program and provides general rules for programming with Embedded SQL. LINKEND="X69910"Chapter 3,  "Communicating with SQL 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. LINKEND="X83688"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. LINKEND="X18559"Chapter 5,  "Connecting to SQL Server,"
 explains how to use Embedded SQL to connect an application program to SQL Server and data servers, in general.LINKEND="X35507"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.LINKEND="X96546"Chapter 7,  "Using Dynamic SQL,"
 describes how to create Embedded SQL statements that your application's users can enter interactively at run time. LINKEND="X73403"Chapter 8,  "Handling Errors,"
 describes return codes and the Embedded SQL precompiler's facilities for detecting and handling errors.LINKEND="X85720"Appendix A,  "Precompiler Warning and Error Messages"LINKEND="X43986"Appendix B,  "Typedefs and Limits"LINKEND="X48723"Appendix C,  "Embedded SQL Constructs"LINKEND="X62331""Glossary"RENDERAS="SECT1"Related DocumentsREMAP="BO--Body"This guide is one of several manuals important to your complete understanding of Embedded SQL. The following illustration shows the other manuals you may need to consult. FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig1.xwd"LBL="Figure 1: "Related DocumentsRENDERAS="SECT2"Other Sources of InformationREMAP="BO--Body"To order additional documentation, see the "Document Orders" section at the front of this book.RENDERAS="SECT1"Syntax ConventionsREMAP="BO--Body"This section describes font style and naming conventions used in this book. MARK="BULL" REMAP="BU--Bullet"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. MOREINFO="NONE"Constant width type indicates keywords you enter exactly as shown. Italic type indicates syntax elements that you supply. In the following example, MOREINFO="NONE"cursor is a keyword, and cursor_name represents a user-supplied identifier: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    exec sql declare cursor_name cursor for         select_statement; Embedded SQL keywords are not case sensitive. You can enter them in upper, lower, or mixed case. This guide lists Embedded SQL keywords in lower case. For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    exec sqlSquare brackets indicate that a word or phrase is optional. In the following example, MOREINFO="NONE"at MOREINFO="NONE"connection_name is optional: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    exec sql [at connection_name] Ellipses (...) indicate that you can repeat the item before them as many times as necessary. In the following example, one or more columns and one or more host variables can be listed: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    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 MOREINFO="NONE"whenever statement, for example, gives a choice of three conditions and four actions: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql whenever {sqlerror | sqlwarning | not found} {continue | goto label | call function_name([param [, param]...]) | stop};A Note calls out important information. For example:When using MOREINFO="NONE"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 MOREINFO="NONE"exec sql statement, enter MOREINFO="NONE"sp_syntax "exec sql". A Warning alerts you to the possibility of an action that could damage a file, result in the loss of data, or cause the system to fail. For example:The precompiler generates variables, all of which begin with "SQL". Do not begin your variables with "SQL--", or you may receive an error message and/or unreliable data.RENDERAS="SECT1"If You Need HelpREMAP="BO--Body"Help with your SYBASE software is available in the form of documentation and the Technical Support Center.RENDERAS="SECT2"On-Line HelpREMAP="BO--Body"If you have access to a 10.0 SQL Server, you can use MOREINFO="NONE"sp_syntax, a SYBASE system procedure, to retrieve the syntax of Embedded SQL statements. For information on how to install MOREINFO="NONE"sp_syntax, see the System Administration Guide Supplement for your platform. For information on how to run MOREINFO="NONE"sp_syntax, see its manual page in Volume 2 of the SQL Server Reference Manual.When using sp_syntax to retrieve a statement's syntax, enclose the statement in quotation marks (" "). For example, to get a display of the syntax for the MOREINFO="NONE"exec sql statement, enter MOREINFO="NONE"sp_syntax "exec sql".RENDERAS="SECT2"Technical SupportREMAP="BO--Body"Each SYBASE installation has a designated person who may contact Technical Support. If using the manuals does not resolve your problem, ask the designated person at your site to contact Sybase Technical Support.REMAP="BO--Body"REMAP="BO--Body"NUMBER="1" ID="X26480"Introduction ID="IN1-3421"Embedded SQLREMAP="BO--Body"This chapter introduces Embedded SQL and the Embedded SQL precompiler. 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.RENDERAS="SECT1"What Is Embedded SQL?   ID="IN1-3422"Embedded SQLdefinitionREMAP="BO--Body"SYBASE Open Client Embedded SQL is a product that enables you to create programs that access and update SQL Server data. Embedded SQL programmers write SQL statements directly into an application program written in a conventional programming language such as C or COBOL. A preprocessing program-the Embedded SQL precompiler-processes the completed application program, resulting in a program that the host language compiler can compile. The program is linked with Open Client -LibraryTM before it is executed.REMAP="BO--Body"Embedded SQL is one of the two programming methods Sybase provides for accessing SYBASE SQL ServerTM. The other programming method is the call-level interface. With the call-level interface, you place Client-Library calls directly into an application program, then link with Client-Library. See the Embedded SQL Programmer's Guide for a comparison of the two methods.REMAP="BO--Body"You can place Embedded SQL statements anywhere in a host program and mix them with host language statements. All Embedded SQL statements must begin with the keywords "MOREINFO="NONE"exec sql" and end with a semicolon (;). ID="IN1-3423"Host variablesREMAP="BO--Body"You can use host variables in Embedded SQL statements to store data retrieved from SQL Server and as parameters in Embedded SQL statements, such as in the MOREINFO="NONE"where clause of a MOREINFO="NONE"selectID="IN1-3424"Dynamic SQL
 statement. In Dynamic SQL, host variables can also contain text for Embedded SQL statements. REMAP="BO--Body"After you write an Embedded SQL program, run it through the precompiler, which translates the Embedded SQL statements into Client-Library function calls.REMAP="BO--Body"The following graphic shows how the System 10 precompiler fits into and functions within the System 10 product line.FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig1_1.xwd"LBL="Figure 1-1: " ID="X54730"The Embedded SQL Precompiler and the System 10 Product LineID="X13282" RENDERAS="SECT1"Why Use Embedded SQL?   ID="IN1-3425"Embedded SQLadvantagesREMAP="BO--Body"Embedded SQL provides several advantages over a call-level interface: MARK="BULL" REMAP="BU--Bullet"Embedded SQL is easy to use because it is simply Transact-SQL with some added features that facilitate using it in an application.It is an ANSI/ISO-standard programming language. It requires less coding to achieve the same results as a call-level approach.Embedded SQL is essentially identical across different host languages. Programming conventions and syntax change very little. Therefore, to write applications in different languages, you need not learn new syntax.ID="IN1-3426"Stored procedures
ID="IN1-3337"Embedded SQLThe precompiler can optimize execution time by generating stored procedures for the Embedded SQL statements. ID="IN1-3248"Features and enhancementsID="X50631" RENDERAS="SECT1"New Features and EnhancementsREMAP="BO--Body"This section describes the enhancements and new features for Embedded SQL System 10. The product is fully compliant with ISO and ANSI SQL-89 precompiler standards. System 10 offers:MARK="BULL" REMAP="BU--Bullet"SQL cursor support FIPS flagger support Support for ISO/ANSI SQL2 Dynamic SQL ANSI and host language datatypesImproved stored procedures supportSupport for Transact-SQL statement batches Compatibility with other ANSI-89-compliant precompilersRun-time library replaced by System 10 Client-Library interfaceID="IN1-3249"LocalizationLocalization support, including multi-byte character setsID="IN1-32410"Features and enhancementscursor supportRENDERAS="SECT2"Cursor SupportREMAP="BO--Body"In previous releases, cursor support was handled in the run-time library. With the current release, cursor support is a SQL Server function. This results in faster and simpler execution and improved locking capabilities
.ID="IN1-30611"Features and enhancementsFIPS flagger
ID="IN1-28812"FIPS flaggerRENDERAS="SECT2"FIPS FlaggerREMAP="BO--Body"The FIPS (Federal Information Processing Standards) implementation upholds the goal of SQL standardization by issuing a warning when it encounters SYBASE extensions to SQL statements. FIPS uses SQL-89 as the standard. REMAP="BO--Body"When you set the optional FIPSID="IN1-28813"Triggers
ID="IN1-28814"Stored procedures
 flagger, you can use Transact-SQL extensions such as triggers and stored procedures. FIPS flags these non-ANSI statements and issues warning messages, but the application still compiles and executes. ID="IN1-28815"Features and enhancementsDynamic SQLRENDERAS="SECT2"Dynamic SQL SupportREMAP="BO--Body"Dynamic SQL lets a user define and execute SQL statements at run time. It accepts a set of Embedded SQL statements that a user submits to the database via an on-line application. Embedded SQL supports SQL2 Dynamic SQL.ID="IN1-261016"Features and enhancementsANSI datatype
ID="IN1-241217"ANSIID="X20806" RENDERAS="SECT2"ANSI Datatype SupportREMAP="BO--Body"To comply with the ANSI SQL-89 standard, Embedded SQL supports the three new SQL datatypes: numeric, decimal, and double-precision.ID="IN1-241218"Features and enhancementsstored proceduresRENDERAS="SECT2"Stored Procedure SupportID="IN1-241219"Stored proceduresREMAP="BO--Body"The precompiler can create stored procedures for all Transact-SQL statements that are legal in stored procedures. This results in faster compile time, since the procedure compiles once and is saved for reuse.REMAP="BO--Body"The precompiler supports Transact-SQL statements that are not allowed as text within a stored procedure. Examples of such statements are MOREINFO="NONE"create trigger and MOREINFO="NONE"create view.ID="IN1-241220"Batch support
ID="IN1-241221"Features and enhancementsbatchesRENDERAS="SECT2"Batch Support REMAP="BO--Body"You can issue multiple SQL statements as a group, or batch
. Batch statements cannot return result sets.RENDERAS="SECT2"Precompiler CompatibilityREMAP="BO--Body"SYBASE Embedded SQL is completely ANSI-89-compliant. Therefore, it is compatible with other precompilers that conform to ANSI-89 standards.To run programs created for pre-System 10 precompilers, you must precompile them again with System 10 and make changes, if necessary. For details, see LINKEND="X39290""Backward Compatibility" 
. ID="IN1-241222"LibraryClient-LibraryRENDERAS="SECT2"Client-Library Run-Time LibraryREMAP="BO--Body"In previous releases, Embedded SQL had its own run-time library. The current release uses SYBASE Open Client Client-Library as the run-time library. This results in simpler execution and less maintenance, since you no longer need to link to an extra run-time library. Also, this approach simplifies debugging generated code, since all function calls are documented in the Open Client Client-Library Reference Manual.ID="IN1-241223"LocalizationRENDERAS="SECT2"LocalizationID="IN1-231324"Features and enhancementsREMAP="BO--Body"An Embedded SQL application program can make calls to CS-Library routines which specify:MARK="BULL" REMAP="BU--Bullet"A language, character set
, and collating sequenceHow to represent dates, times, and numeric and monetary values in character formatSee the platform-specific Open Client/Server Supplement for details.ID="IN1-231325"Transact-SQLsupportID="X71542" RENDERAS="SECT1"Transact-SQL Support in Embedded SQLREMAP="BO--Body"With the exception of MOREINFO="NONE"print, MOREINFO="NONE"raiserror, MOREINFO="NONE"readtext, and MOREINFO="NONE"writetext, all Transact-SQL statements, functions, and control-of-flow language are valid in Embedded SQL. You can develop an interactive prototype of your Embedded SQL application in Transact-SQL to facilitate debugging your application, then easily incorporate it into your application. REMAP="BO--Body"Most SQL Server datatypes have an equivalent in Embedded SQL. Also, you can use host language datatypes in Embedded SQL. Many datatype conversions occur automatically when a host language datatype does not exactly match a SQL Server datatype. ID="IN1-231326"Variableshost
ID="IN1-231327"Transact-SQLinvalid keywords in Embedded SQLREMAP="BO--Body"You can place host language variables in Embedded SQL statements wherever literal quotes are valid in Transact-SQL. Enclose the literal with either single (`) or double (") quotation marks. For information on delimiting literals that contain quotation marks, see the SQL Server Reference Manual.REMAP="BO--Body"Embedded SQL has several features that Transact-SQL does not have: MARK="BULL" REMAP="BU--Bullet"ID="IN1-231328"Datatype conversions
ID="IN1-231329"Conversion, datatype
Automatic datatype conversion occurs between host language types and SQL Server types. Dynamic SQL lets you define SQL statements at run time. SQLCA, SQLCODE, and SQLSTATE let you communicate between SQL Server and the application program. The three entities contain error, warning, and informational message codes that SQL Server generates.ID="IN1-231330"Return codetesting
Return code testing routines detect error conditions during execution.ID="X33123" RENDERAS="SECT1"Getting Started REMAP="BO--Body"Before attempting to run the precompiler, make sure Client-Library System 10 is installed, as the precompiler uses it as the run-time library. Also, make sure SQL Server
 System 10 is installed. If one or more products is missing, contact your System Administrator
.REMAP="BO--Body"Invoke the precompiler by issuing the appropriate command at the operating system prompt. See the platform-specific Open Client/ Server Supplement for details.REMAP="BO--Body"Associated with the precompiler command are several flags that let you determine options for the precompiler, including the input file, login user name and password, and precompiler modes. The Open Client/Server Supplement contains operating system-specific information on precompiling, compiling, and linking your Embedded SQL application. RENDERAS="SECT2"Using the ExamplesID="IN1-211531"pubs2 database
ID="IN1-191732"Databasepubs2REMAP="BO--Body"The examples in this guide use the SQL Server pubs2 database. To run the examples, specify the pubs2 database with the Transact-SQL MOREINFO="NONE"use statement. REMAP="BO--Body"Embedded SQL is shipped with several on-line examples. For information on running these examples, see the Open Client/Server Supplement for your platform. ID="IN1-181833"CompatibilitybackwardID="X39290" RENDERAS="SECT2"Backward Compatibility REMAP="BO--Body"The System 10 precompiler is compatible with precompilers that are SQL-89-compliant. However, you may have applications created with earlier Embedded SQL releases which are not ANSI compliant. This precompiler uses most of the same Embedded SQL statements used in previous precompiler versions, but it processes them differently.REMAP="BO--Body"Follow this procedure to migrate applications created for earlier precompiler releases:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Remove the following SQL statements and keywords from the application, as System 10 does not support them:MOREINFO="NONE"          release   connection_nameMOREINFO="NONE"          recompile           noparse          noproc          pcoptionsID="IN1-171934"Compatibilitybackward
 If you fail to do this, MOREINFO="NONE"release will generate an error, and the precompiler will ignore the other keywords.ID="IN1-171935"Parameter markerdynamic
ID="IN1-171936"MarkerdynamicChange the parameter marker for Dynamic SQL statements from ":dummy" to "?". The current release uses "?" as the dynamic parameter marker.Update error-handling routines to reflect the new SQLCA fields.Use the System 10 precompiler to re-precompile the application.ID="IN1-171937"Programcreating
ID="IN1-162038"Embedded SQL programcreatingID="X40981" RENDERAS="SECT1"Creating and Running an Embedded SQL Program   REMAP="BO--Body"Follow these steps to create and run an Embedded SQL application program: NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Write the application program and include the Embedded SQL statements and variable declarations. Save the application in a file with a .cp extension. Precompile the application. If there are no severe errors, the precompiler generates a file containing your application program. The file has the same name as the original source file, with a different extension, depending on the requirements of your C compiler. For details, see the Open Client/Server Supplement for your platform.Compile the new source code as you would compile a standard C program. Link the compiled code with Client-Library. ID="IN1-142239"isqlIf you specified the precompiler option to generate stored procedures, load them into SQL Server by executing the generated script with MOREINFO="NONE"isql. Run the application program as you would any standard C program.ID="IN1-142240"ExecutablebuildingREMAP="BO--Body"This is a representation of building an Embedded SQL executableID="IN1-132341"Embedded SQL programcreating
. FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig1_2.xwd"LBL="Figure 1-2: "Embedded SQL: Building an ExecutableID="IN1-122442"PrecompilerfunctionalityID="X86283" RENDERAS="SECT1"How the Precompiler Processes Your Applications   REMAP="BO--Body"The Embedded SQL precompiler translates Embedded SQL statements into C data declarations and call statements. After precompiling, you can compile the resulting source program as you would any conventional C program. ID="IN1-122443"ParseREMAP="BO--Body"The precompiler processes an application in two passes. In the first pass, the precompiler parses the Embedded SQL statements and variable declarations, checking the syntax and displaying messages for any errors it detects. If the precompiler detects no severe errors, it proceeds with the second pass, wherein it:MARK="BULL" REMAP="BU--Bullet"Adds declarations for the precompiler variables, which begin with "_sql". To prevent confusion, do not begin your variables' names with "_sql"Converts the text of the original Embedded SQL statements to commentsGenerates stored procedures and calls to stored procedures if you set this option in the precompile commandConverts Embedded SQL statements to Client-Library calls. Embedded SQL uses Client-Library
 as a run-time libraryID="IN1-122444"Filesprecompiler-generated
ID="IN1-122445"Multiple source files
ID="IN1-122446"Filesmultiple
ID="IN1-122447"Source filesmultipleGenerates up to three files: a ID="IN1-122448"Target file
target file
, an optional ID="IN1-122449"Listing file
listing file
, and an optional ID="IN1-102650"isql file
isql script file
ID="IN1-102651"Precompiler command line options
ID="IN1-102652"Command line options, precompilerFor detailed descriptions of precompiler command line options, see the platform-specific Open Client/Server Supplement.ID="IN1-102653"FilesmultipleID="IN1-102654"Multiple source filesID="IN1-102655"Source filesmultipleRENDERAS="SECT2"Multiple Embedded SQL Source FilesREMAP="BO--Body"If the Embedded SQL application consists of more than one source file, the following statements apply:MARK="BULL" REMAP="BU--Bullet"Connection names are unique and global to the entire application.Cursor names are unique for a given connection.Prepared statement names are global to the connection.Dynamic descriptors are global to the application.RENDERAS="SECT2"ID="IN1-92756"Precompilerfunctionality
Precompiler-Generated Files REMAP="BO--Body"The target file is similar to the original input file, except that all SQL statements are converted to Client-Library run-time calls. REMAP="BO--Body"The listing file contains the input file's source statements, plus any informational, warning, or error messages.REMAP="BO--Body"The MOREINFO="NONE"isqlID="IN1-92757"Stored procedures
 script file contains the precompiler-generated stored procedures. The stored procedures are written in Transact-SQL
.RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter introduced Embedded SQL and the Embedded SQL precompiler. The next chapter, "General Information," describes the five parts of an Embedded SQL program and presents basic Embedded SQL rules. REMAP="BO--Body"NUMBER="2" ID="X56073"General InformationREMAP="BO--Body"This chapter provides general information about Embedded SQL.RENDERAS="SECT1"ID="IN2-3511"RequirementsEmbedded SQL
Five Tasks of Creating an Embedded SQL ProgramREMAP="BO--Body"In addition to containing the host language code, an Embedded SQL program performs five tasks. Each Embedded SQL program must perform all these tasks to precompile, compile, and execute. Subsequent chapters discuss these five tasks.FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig2_1.xwd"LBL="Figure 2-1: " ID="X25484"Five Tasks of an Embedded SQL ProgramID="IN2-3512"Embedded SQLsample programRENDERAS="SECT2"Simplified Embedded SQL ProgramREMAP="BO--Body"Following is a simple Embedded SQL program. At this point, you need not understand everything shown in the program. Its purpose is to demonstrate the parts of an Embedded SQL program. The details are explained in subsequent chapters. REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"/* Establishing a communication area - Chapter 3 */ exec sql include sqlca;  main() {  /* Declaring variables - Chapter 4 */ exec sql begin declare section; CS_CHAR  user[31], passwd[31]; exec sql end declare section;      /*Initializing error-handling routines - Chapter 8 */  exec sql whenever sqlerror perform err_p();  /*Establishing SQL Server connections - Chapter 5 */ printf("\nplease enter your userid "); gets(user); printf("\npassword "); gets(passwd); exec sql connect :user identified by :passwd;  /* Issuing Transact-SQL statements  -  Chapter 6 */ exec sql update titles set price = price * 1.10;  /* Closing server connections - Chapter 5 */ exec sql disconnect; }REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"/* Error-handling routines - Chapter 8 */ err_p() {     /* Print the error code, error message,     * and line number of the statement that caused    * the error. */  printf("\nerror at source line %d code %d.\n%s",     sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); } ID="IN2-3513"RulesEmbedded SQL
ID="IN2-3514"Embedded SQLrulesID="X89139" RENDERAS="SECT1"General Rules for Embedded SQL   ID="IN2-3515"Case sensitivityEmbedded SQLREMAP="BO--Body"The following rules apply to Embedded SQL statements in C programs:MARK="BULL" REMAP="BU--Bullet"Embedded SQL statements begin with these keywords: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sqlEmbedded SQL statements must end with a semicolon:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql sql_statement;Place MOREINFO="NONE"exec MOREINFO="NONE"sql at the beginning of the source line except when a C label precedes it:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"[label:] exec sql sql_statement;Embedded SQL keywords are not case sensitive. MOREINFO="NONE"exec MOREINFO="NONE"sql, EXEC SQL, MOREINFO="NONE"Exec Sql, or any other mixture of case is equally valid. This guide consistently shows Embedded SQL keywords in lower case. For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql commit work; ID="IN2-3516"PlacementEmbedded SQL statementsRENDERAS="SECT2"Statement Placement ID="IN2-3517"StatementsEmbedded SQLREMAP="BO--Body"An application program can have Embedded SQL statements wherever C statements are valid. ID="IN2-3518"Commentsin Embedded SQLRENDERAS="SECT2"Comments   REMAP="BO--Body"Comments placed within Embedded SQL and C statements must follow one of two conventions. The Transact-SQL convention is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"/* comments */ REMAP="BO--Body"The ANSI convention is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"-- comments  REMAP="BO--Body"This guide uses the ANSI comment style.REMAP="BO--Body"Comments placed outside of SQL statements must conform to C programming conventions. ID="IN2-3519"IdentifiersEmbedded SQLRENDERAS="SECT2"Identifiers   REMAP="BO--Body"Identifiers are used as function or variable names within your application. ID="IN2-35110"Quotation marksin Embedded SQLRENDERAS="SECT2"Quotation Marks   REMAP="BO--Body"Enclose literal character strings in Embedded SQL statements within single or double quotation marks. If a character string begins with a double quotation mark, end it with a double quotation mark. If a character string begins with a single quotation mark, end it with a single quotation mark. ID="IN2-35111"Reserved wordsEmbedded SQLRENDERAS="SECT2"Reserved Words   ID="IN2-35112"KeywordsEmbedded SQL
ID="IN2-35113"Transact-SQLkeywords in Embedded SQLREMAP="BO--Body"Do not use C, Transact-SQL, or Embedded SQL reserved words except as intended by the languages. See Appendix C for a list of valid constructs in Embedded SQL.REMAP="BO--Body"You can write Embedded SQL keywords in upper, lower, or mixed case. This guide shows Embedded SQL keywords in lower case. ID="IN2-35114"Variablesnaming conventions
ID="IN2-35115"Naming conventionsvariablesRENDERAS="SECT2"Variable Naming Conventions   REMAP="BO--Body"Embedded SQL variables must conform to C naming conventions. Do not place variable names within quotation marks. Applicable quotation marks are inserted automatically when the variable names are replaced with actual values. ID="IN2-35116"Variablesprecompiler
ID="IN2-35117"_sqlREMAP="BO--Body"While parsing the application, declarations are added for precompiler variables. These variables begin with "_sql". So, to avoid confusion, do not begin variable names with "_sql".ID="IN2-35118"ScopingRENDERAS="SECT2"Scoping Rules   REMAP="BO--Body"Embedded SQL and precompiler-generated statements adhere to host language
 scoping rules. The MOREINFO="NONE"whenever statement and cursor names are exceptions.RENDERAS="SECT2"Statement Batches ID="IN2-35119"BatchesstatementsREMAP="BO--Body"As in Transact-SQL, you can batch several SQL statements in a single MOREINFO="NONE"exec MOREINFO="NONE"sql statement. Batches are useful and more efficient when an application must execute a fixed set of Transact-SQL statements each time it runs.REMAP="BO--Body" For example, some applications create temporary tables and indexes when they start up. You could send these statements in a single batch. See the SQL Server Reference Manual for rules about statement batches. ID="IN2-35120"BatchesrestrictionsREMAP="BO--Body"The following restrictions apply to statement batches: ID="IN2-33321"selectMARK="BULL" REMAP="BU--Bullet"Statements in a batch cannot return results to the program. That is, a batch can contain no MOREINFO="NONE"select statements. All statements in a batch must be valid Transact-SQL statements. You cannot place Embedded SQL statements such as MOREINFO="NONE"declare cursor and MOREINFO="NONE"prepare in a statement batch. The same rules that apply to Transact-SQL batches apply to Embedded SQL batches. For example, you cannot put a MOREINFO="NONE"use database statement in an Embedded SQL batch.RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter introduced the basic Embedded SQL rules and the parts of an Embedded SQL program. The next chapter explains how to use a SQL communication area (via SQLCA, SQLCODE, or SQLSTATE), which receives status information from SQL Server.NUMBER="3" ID="X69910"Communicating with SQL ServerREMAP="BO--Body"This chapter explains how to enable an application program to receive status information from SQL Server. To create a communication path and declare system variables to be used in communications from SQL Server to the application, you must create one of three entities:MARK="BULL" REMAP="BU--Bullet"A SQL Communication Area (SQLCA), which includes SQLCODEA stand-alone SQLCODE long integerA SQLSTATE character arrayREMAP="BO--Body"SQLCODE, SQLCA, and SQLSTATE are variables to be used in communication from SQL Server to the application.ID="IN3-3511"Return codeREMAP="BO--Body"After SQL Server executes each Embedded SQL statement, it stores return codes in SQLCA, SQLCODE, or SQLSTATE. An application program can access the variables to determine whether the executed SQL statement succeeded or failed.The precompiler automatically setsID="IN3-3332"SQLCA variablessetting
 SQLCA, ID="IN3-3153"SQLCODE variablessetting
SQLCODE, and ID="IN3-2974"SQLSTATE variablessetting
SQLSTATE variables, which are critical for run-time access to the database. You need not initialize or modify them.REMAP="BO--Body"For details on detecting and handling errors, multiple error messages, and other return codes, see Chapter 8, "LINKEND="X73403"Handling Errors
."RENDERAS="SECT1"RENDERAS="SECT2"ID="IN3-23135"Scoping SQLCA, SQLCODE, and SQLSTATE
Scoping Rules: SQLCA, SQLCODE, and SQLSTATEREMAP="BO--Body"You can declare SQLCAID="IN3-23136"Scoping
 anywhere in the application program where a C variable can be declared. The scope of the structure follows C scoping rules.REMAP="BO--Body"If you declare SQLCA, SQLCODE, or SQLSTATE within your file, each variable must be in scope for all executable Embedded SQL statements in the file. The precompiler generates code to set each of these status variables for each Embedded SQL statement. So, if the variables are not in scope, the generated code will not compile.REMAP="BO--Body"If you do not declare SQLCA, SQLCODE, or SQLSTATE within the file being passed to the precompiler, you must declare SQLCODE within a referenced file. The precompiler assumes a declaration of SQLCODE, and generates code to this effect.ID="IN3-21157"SQLCAdeclaringID="X14957" RENDERAS="SECT1"Declaring SQLCAAlthough SQLSTATE is preferred over SQLCODE and SQLCA this release only fully supports SQLCODE. A future release will support SQLSTATE.REMAP="BO--Body"The syntax for declaring SQLCA is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql include sqlca; ID="IN3-19178"includeREMAP="BO--Body"You can use the Embedded SQL MOREINFO="NONE"include statement to include other files into your application the same way you would use the C preprocessor #include command.You can also set a precompiler command option to specify an ID="IN3-19179"Include file directory
includeID="IN3-191710"Filesdirectory
ID="IN3-191711"Directoriesand searches
 file directory. At precompile time, the precompiler searches the path specified in the C compile command. The precompiler uses the include file path to search for this file. It opens and reads the included file as if were part of the MOREINFO="NONE"main file. If the included file cannot be found, the precompile fails.RENDERAS="SECT2"ID="IN3-171912"SQLCAmultiple
ID="IN3-152113"Multiple SQLCAs
Multiple SQLCAsREMAP="BO--Body"You may have multiple SQLCAs, but each must follow C scoping rules for host variables. Each SQLCA need not be in a separate scope.RENDERAS="SECT2"ID="IN3-122414"SQLCA variables
SQLCA VariablesID="IN3-102615"sqlca variableslist of
ID="IN3-102616"Variablessystem
   REMAP="BO--Body"When the precompiler encounters the MOREINFO="NONE"include sqlca statement, it inserts the SQLCA structure declaration into the application program. SQLCAID="IN3-102617"System variables
 is a data structure containing precompiler-determined system variables, each of which can be accessed independently. Your application program should never directly alter these variables.REMAP="BO--Body"SQLCA variables pass information to your application program about the status of the most recently executed Embedded SQL statement.ID="IN3-82818"SQLCAtableREMAP="BO--Body"The following table describes the SQLCAID="IN3-63019"sqlca variablesSQL Server-related
 variables that hold status information, return codes, error codes, and error messages generated by SQL Server:TOCENTRY="1"LBL="Table 3-1: " ID="X94948"SQL Server SQLCA Variables COLS="3" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="90*"COLNAME="C2" COLWIDTH="81*"COLNAME="C3" COLWIDTH="189*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SQL Server SQLCA Variables COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"VariableCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"DatatypeCOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"Description VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcaidCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"charCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Text string that contains "sqlca".COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcabcCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"longCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Length of SQLCA.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcodeCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"longCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Contains the return code of the most 
recently executed SQL statement. 

See "SQLCODE Values"  for return code 
definitions. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[0] to 
sqlwarn[7]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"charCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning flags. Each flag indicates 
whether a warning has been issued: a 
`W' for warning, or a blank space for no 
warning. 

Chapter 8 describes the sqlwarn flags. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlerrm.sqlerrmc[ ]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"charCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error message. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlerrm.sqlerrmlCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"longCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error message length.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlerrpCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"charCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Program that detected error/warning.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlerrd[6]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"longCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Details of error/warning. [2] is the 
number of rows affected.RENDERAS="SECT2"ID="IN3-33320"SQLCA variables
Accessing SQLCA VariablesID="IN3-13521"SQLCA variablesaccessing
 ID="IN3--13722"sqlca variablesaccessingREMAP="BO--Body"SQLCA variables are members of a C structure, sqlca, that is declared by the MOREINFO="NONE"include MOREINFO="NONE"sqlca statement. To access SQLCA variables, use the C structure member operator (.), as in the following example: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"if (sqlca.sqlwarn[1] == 'W')  {     printf("\nData truncated;     return; } REMAP="BO--Body"You can also pass the address of the sqlca structure to a function, then access the SQLCA variables within that function with the -> operator. The following example shows a function that works this way: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"warning(p)  struct sqlca *p;  {     if (p->sqlwarn[3] == 'W')         printf("\nIncorrect number of variables in        fetch.");     printf("\nExpected %d host variables.");      return;      }REMAP="BO--Body"SQLCA variables are useful for determining whether an Embedded SQL statement executed successfully. The other SQLCAID="IN3--13723"Return code
ID="IN3--13724"System variables
ID="IN3--33925"sqlca
 variables listed in the previous section provide additional information about errors and return codes to help in debugging as well as the normal processing of your application. RENDERAS="SECT2"ID="IN3--74326"SQLCODEwithin SQLCA
SQLCODE within ID="IN3--114727"SQLCODEwithin SQLCA
SQLCAREMAP="BO--Body"The application should test sqlcode after each statement executes, because SQL Server updates it after each execution. As a rule, use the MOREINFO="NONE"whenever statement, described in Chapter 8, "LINKEND="X73403"Handling Errors
," to perform this task. ID="IN3--134928"SQLCODEas a stand-aloneID="X25242" RENDERAS="SECT1"Declaring SQLCODEID="IN3--155129"SQLCODEas a stand-alone
 as a Stand-AloneAlthough SQLSTATE is preferred over SQLCODE and SQLCA, this release only fully supports SQLCODE. A future release will support SQLSTATE.REMAP="BO--Body"As an alternative to creating a SQLCA, use SQLCODE independently. It contains the return code of the most recently executed SQL statement. The benefit of using SQLCODE as a stand-alone is its execution speed. If you have no need to review the other information that SQLCAID="IN3--175330"Return codeSQLCODE
 holds and are solely interested in return codes, consider using SQLCODE.REMAP="BO--Body"Despite SQLCODE's faster execution speed, SQLSTATE is preferred over SQLCODE. SQLCODE is a deprecated feature that is supported for compatibility with earlier versions of Embedded SQL.In a future release, you will be advised to use SQLSTATE instead of SQLCODE for receiving status results.REMAP="BO--Body"Following is an example of declaring SQLCODE as a stand-alone:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"long SQLCODE;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql open cursor pub_id;    while (sqlcode = = 0)    {    exec sql fetch pub_id into :pub_name;REMAP="BO--Body"For details on debugging any errors SQLCODE indicates, see Chapter 8, "LINKEND="X73403"Handling Errors
"REMAP="BO--Body"Following is a table of SQLCODEID="IN3--195531"SQLCODE valuestable
ID="IN3--215732"SQLCODEvalues
 values:TOCENTRY="1"LBL="Table 3-2: "SQLCODE Values COLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="90*"COLNAME="C2" COLWIDTH="189*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SQLCODE Values COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ValueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Description VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"0COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Statement executed successfully.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"-nCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error occurred. See Server or Client-
Library error messages."n" represents 
the number associated with the error or 
exception.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"+100COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"No data exists, no rows left after MOREINFO="NONE"fetch, or 
no rows met search condition for MOREINFO="NONE"update, 
MOREINFO="NONE"delete, or MOREINFO="NONE"insert.ID="IN3--235933"SQLSTATEusingID="X61524" RENDERAS="SECT1"Using SQLSTATEAlthough SQLSTATE is preferred over SQLCODE and SQLCA features, this release only fully supports SQLCODE. A future release will support both SQLCA and SQLSTATE.REMAP="BO--Body"SQLSTATE is a status parameter. Its codes indicate the status of the most recently attempted procedure- either the procedure completed successfully or an error occurred during the execution of the procedure.REMAP="BO--Body"SQLSTATE is a character string parameter whose exceptions values are described in the following table:TOCENTRY="1"LBL="Table 3-3: "SQLSTATE ValuesCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="135*"COLNAME="C2" COLWIDTH="135*"VALIGN="BOTTOM"COLNAME="C1" NAMEST="C1" NAMEEND="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SQLSTATE ValuesCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ValueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"DescriptionVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"00XXXCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Successful executionCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"01XXXCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"02XXXCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"No data exists; no rows 
affectedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Any other valueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ErrorRENDERAS="SECT2"ID="IN3--256134"SQLSTATECodes and error messages
Obtaining SQLSTATE Codes and Error MessagesID="IN3--276335"ErrorsSQLSTATEREMAP="BO--Body"SQLSTATE messages can be informational, warnings, severe, or fatal. SQL-Server and Open Client Client-Library generate the majority of SQLSTATE messages. See the appropriate documentation for a complete list of SQLSTATE codes and error messages.REMAP="BO--Body"See LINKEND="X85720"Appendix A,  "Precompiler Warning and Error Messages"
 for the table of SQLSTATE messages that the precompiler can generate.RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter explained SQLCA, SQLCODE, and SQLSTATE. After a statement executes, SQL Server stores return codes and information in SQLCA variables, in a stand-alone SQLCODE area, or in SQLSTATE. These return codes indicate the failure or success of the statement that most recently executed.REMAP="BO--Body"The next chapter, "Using Variables," explains host variables and indicator variables, which pass data from your application to SQL Server.REMAP="BO--Body"NUMBER="4" ID="X83688"Using Variables REMAP="BO--Body"The previous chapter introduced   SQLCA, SQLCODE, SQLSTATEID="IN4-3511"Variablesindicator
-or system variables and their role in communications from SQL Server to your application program. This chapter details the following two types of variables that pass data between your application and SQL Server: MARK="BULL" REMAP="BU--Bullet"Host variables, which are C variables you use in Embedded SQL statements to hold data that is retrieved from and sent to SQL ServerIndicator variables, which you associate with host variables to indicate null data and data truncationID="X26978" RENDERAS="SECT1"Declaring VariablesID="IN4-3512"Variablesinput
ID="IN4-3513"Host variablesdeclaring
ID="IN4-3514"Variablesdeclaring
ID="IN4-3515"Variables
ID="IN4-3516"Indicator variablesdeclaring
ID="IN4-3517"Variablessystem
ID="IN4-3518"System variablesREMAP="BO--Body"As discussed in Chapter 3, the precompiler automatically sets the system variables when you include SQLCA, SQLCODE, or SQLSTATE in the application program. However, you must explicitly declare host and indicator variables in a ID="IN4-3339"declare section
MOREINFO="NONE"declare section before using them in Embedded SQL statements.The precompiler generates some variables, all of which begin with "_sql". Do not begin your variables with "_sql", or you may receive an error message and/or unreliable data.REMAP="BO--Body"The precompiler ignores macros and MOREINFO="NONE"#include statements in a MOREINFO="NONE"declare section, and processes MOREINFO="NONE"includeID="IN4-31510"Variables in declare sectionexample
 statements as if the contents of the included file were copied directly into the file being precompiled. The syntax for a MOREINFO="NONE"declare section with an MOREINFO="NONE"include statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; exec sql include "filename";...exec sql end declare section; ID="IN4-29711"declare sectionREMAP="BO--Body"Host variable declarations must conform to the C rules for variable declarations. You need not declare all variables in one MOREINFO="NONE"declare section, since you can have an unlimited number of MOREINFO="NONE"declare sections in a program.ID="IN4-29712"VariablesdeclaringREMAP="BO--Body"When you declare variables, you must also specify the datatype
. See LINKEND="X23443""Datatypes" 
 for valid datatypes. Alternatively, use the Client-Library typedefs, such as CS_CHAR, which are declared in the cspublic.h file, in MOREINFO="NONE"declare sections. REMAP="BO--Body"The following example shows two character strings defined in a MOREINFO="NONE"declare section. ID="IN4-29713"VariablesdeclaringREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; CS_CHAP name[20]; CS_CHAR type[3]; exec sql end declare section; ID="IN4-29714"TypedefsRENDERAS="SECT2"Using TypedefsREMAP="BO--Body"You can use typedefs within a MOREINFO="NONE"declare section to declare variables. For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;    typedef struct    {        CS_CHAR name[20];        CS_CHAR passwd[20];    }    login_rec;    login_rec my_login;exec sql end declare section;ID="IN4-27915"#defineRENDERAS="SECT2"Using #defineREMAP="BO--Body"You can use MOREINFO="NONE"#define values in a MOREINFO="NONE"declare section to dimension arrays and initialize variables. When you use MOREINFO="NONE"#define in a host variable declaration, place it before the host variable declaration that uses it. For example, the following two examples are valid: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"#define PLEN  26 CS_CHAR name[PLEN]; REMAP="BO--Body"and: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; #define  PLEN  26 exec sql end declare section;     ... exec sql begin declare section; CS_CHAR  name[PLEN]; exec sql end declare section; REMAP="BO--Body"You can use MOREINFO="NONE"#define to declare symbolic names. Make the declaration before using it in the application. For example, to define "10" symbolically, use this nomenclature:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;#define count_1 10CS_CHAR var1[count_1];exec sql end declare section;ID="IN4-27916"Character arraydeclaringRENDERAS="SECT2"Declaring a Character ArrayID="IN4-27917"Complex definitionREMAP="BO--Body"The precompiler supports complex definitions, which are structures and arrays. You may nest structures, but you cannot have an array
 of structures.REMAP="BO--Body"The precompiler recognizes single-dimensional arrays of all datatypes. ID="IN4-27918"Arraydouble-dimensional
ID="IN4-27919"Double-dimensional arrayREMAP="BO--Body"The precompiler also recognizes double-dimensional arrays of characters, as the following example demonstrates:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"#define maxrows 25int numsales [maxrows];REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; #define DATELEN 30 #define DAYS_PER_WEEK 7CS_CHAR days_of_the_week[DAYS_PER_WEEK][DATELEN+1]; exec sql end declare section; REMAP="BO--Body"For details on arrays, see LINKEND="X77536""Using Arrays" 
.ID="IN4-27920"Host variablesusing
ID="IN4-27921"VariablesusingID="X91859" RENDERAS="SECT1"Using Host Variables   REMAP="BO--Body"Host variables let you transfer values between SQL Server and the application program. REMAP="BO--Body"Declare the host variable within the application program's Embedded SQL MOREINFO="NONE"declare section. Only then can you use the variable in SQL statements.ID="IN4-27922"Colonsand variablesREMAP="BO--Body"When you use the variable within an Embedded SQL statement, prefix the host variable with a colon. When you use the variable elsewhere in the program, do not use a colon. When you use several host variables successively in an Embedded SQL statement, separate them with commas or follow the grammar rules of the SQL statement. REMAP="BO--Body"The following example demonstrates how to use a variable. user is defined in a MOREINFO="NONE"declare section as a character variable. Then, it is used as a host variable in a MOREINFO="NONE"select statement: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; CS_CHAR  user[32]; exec sql end declare section;  exec sql select user_name() into :user; printf("You are logged in as %s.\n", user); REMAP="BO--Body"There are four ways to use host variables. Use them as:MARK="BULL" REMAP="BU--Bullet"ID="IN4-27923"Variablesinput
Input variables for SQL statements and proceduresID="IN4-27924"Result variableshost
Result variablesID="IN4-27925"Status variableshost
Status variables from calls to SQL proceduresOutput variables for SQL statements and proceduresREMAP="BO--Body"Declare all host variables as described in LINKEND="X26978""Declaring Variables" 
, regardless of their function. Following are descriptions of how to use host variables.ID="IN4-27926"Input variables
ID="IN4-27927"Variableshost input
ID="IN4-27928"Input variableshost
ID="IN4-27929"Host input variablesRENDERAS="SECT2"Host Input VariablesREMAP="BO--Body"ID="IN4-27930"Input variables
These variables pass information to SQL Server. The application program assigns values to them. They hold data used in executable ID="IN4-27931"Variablesinput
statements such as stored procedures, MOREINFO="NONE"select statements with MOREINFO="NONE"where clauses, MOREINFO="NONE"insert statements with MOREINFO="NONE"values clauses, and MOREINFO="NONE"update statements with MOREINFO="NONE"set clauses. REMAP="BO--Body"The following example uses the variables id and publisher as input variables: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;     CS_CHAR d[7];    CS_CHAR publisher[5];exec sql end declare section;    ... exec sql delete from titles where title_id = :id;exec sql update titles set pub_id = :publisher    where title_id = :id;ID="IN4-27932"Result variables
ID="IN4-27933"Variableshost resultRENDERAS="SECT2"Host Result VariablesREMAP="BO--Body"These variables receive the results of MOREINFO="NONE"select and MOREINFO="NONE"fetch statements.REMAP="BO--Body"The following example uses the variable id as a result variable
: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;CS_CHAR  id[5];exec sql end declare section; exec sql select title_id into :id from titles    where pub_id = "0736" and type = "business";ID="IN4-27934"Status variables
ID="IN4-27935"Variableshost status
ID="IN4-27936"Host status variablesRENDERAS="SECT2"Host Status VariablesID="IN4-27937"Status variables
ID="IN4-27938"VariablesstatusREMAP="BO--Body"These variables receive the return status values of stored procedures. Status variables indicate whether the stored procedure completed successfully or the reasons it failed.REMAP="BO--Body"Declare status variables as two-byte integers (CS_SMALLINT). REMAP="BO--Body"The following example uses the variable retcode as a status variable
: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;CS_SMALLINT  retcode; exec sql end declare section; exec sql begin transaction;exec sql exec :retcode = update_proc;if (retcode != 0) {     exec sql rollback transaction;} ID="IN4-27939"Host output variablesRENDERAS="SECT2"Host Output VariablesID="IN4-27940"Output variablesREMAP="BO--Body"These variables pass data from stored procedures to the application program. For more information on stored procedures, see LINKEND="K11111""Using Stored Procedures" in Chapter 6, "Using Transact-SQL Statements". Use host output variables when stored procedures return the value of parameters declared as MOREINFO="NONE"out.REMAP="BO--Body"The following example uses the variables par1 and par2 as output variables: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql exec a_proc :par1 out, :par2 out;ID="IN4-261041"Indicator variablesusing
ID="IN4-261042"Host variableswith indicator variables, usingID="X76820" RENDERAS="SECT1"Using Indicator Variables   REMAP="BO--Body"You can associate indicator variables with host variables to indicate when a database value is null. Use a space and, optionally, the indicaor keyword, to separate each indicator variable from the host variable with which it is associated. Each indicator variable
 must immediately follow its host variable.REMAP="BO--Body"Without indicator variables, Embedded SQL cannot indicate null values.RENDERAS="SECT2"Indicator Variables and Server RestrictionsREMAP="BO--Body"Embedded SQL is a generic interface, and can run on a variety of servers, including SQL Server. REMAP="BO--Body"Because it is generic, Embedded SQL does not enforce or reflect any particular server's restrictions. For example, Embedded SQL allows text and image stored procedure parameters, but SQL Server does not.REMAP="BO--Body"When writing an Embedded SQL application, keep the application's ultimate target server
 in mind. If you are unsure about what is legal on a server and what is not, consult your server documentation.RENDERAS="SECT2"Indicator Variables and Server RestrictionsREMAP="BO--Body"Embedded SQL applications use Client-Library, a generic interface, to run on a variety of servers, including SQL Server. REMAP="BO--Body"Because it is generic, Client Library does not enforce or reflect any particular server's restrictions. For example, Client-Library allows text and image stored procedure parameters, but SQL Server does not.REMAP="BO--Body"When writing a Client-Library application, keep the application's ultimate target server in mind. If you are unsure about what is legal on a server and what is not, consult your server documentation.RENDERAS="SECT2"Using Host Variables with Indicator VariablesREMAP="BO--Body"Declare host and indicator variables in a MOREINFO="NONE"declare section before using them anywhere in an application program containing Embedded SQL statements. Declare indicator variables as two-byte integers (short or CS_SMALLINT) in a MOREINFO="NONE"declare section before using them.ID="IN4-261043"Colonsand indicator variables
ID="IN4-261044"Indicator variablesand colons
ID="IN4-261045"Indicator variable with host variablesexampleREMAP="BO--Body"Prefix indicator variables with a colon when using them in an Embedded SQL statement. The syntax for associating an indicator variable with a host variable is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC":host_variable [[indicator] :indicator_variable]REMAP="BO--Body"The association between an indicator and host variable only lasts the duration of a statement- that is, for the duration of one MOREINFO="NONE"exec sql statement, or between MOREINFO="NONE"open and MOREINFO="NONE"close cursor statements. A value is assigned to the indicator variable at the same time a value is assigned to the host variable. ID="IN4-261046"Host variablesREMAP="BO--Body"The server sets the indicator variable only when you assign a value to the host variable. Therefore, you can declare an indicator variable once and reuse it with different host variables in different statements. REMAP="BO--Body"You can use indicator variables with output, result, and input variables. When used with output and result variables, Embedded SQL sets the variable to indicate the null status of the associated host variable. When used with input variables, you set the value of the indicator variable to show the null status of the input variable
 before submitting it to SQL Server.RENDERAS="SECT3"ID="IN4-261047"Variableshost
Using Indicator Variables with Host Output and Host Result Variables   ID="IN4-261048"Indicator variableswith output and result variablesREMAP="BO--Body"When you associate an indicator variable with an output or result variable, Client-Library automatically sets it to one of the following values: TOCENTRY="1"LBL="Table 4-1: " ID="X61933"Indicator Variable Values when Used with Output or Result VariableCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="63*"COLNAME="C2" COLWIDTH="297*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ValueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MeaningVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"    -1COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The corresponding database column in SQL Server contains a 
null value. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"     0COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"A non-null value was assigned to the host variable. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"   >0 COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"An overflow occurred while converting data for the host 
variable. The host variable contains truncated data. The positive 
number represents the length, in bytes, of the value before it was 
truncated. REMAP="BO--Body"The following example demonstrates associating the indicator variable indic with the result variable id: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; CS_CHAR          id[6]; CS_SMALLINT      indic; CS_CHAR          pub_name[41];  exec sql end declare section;  exec sql select pub_id into :id indicator :indic      from titles where title      like "%Stress%"; if (indic == -1){     printf("\npub_id is null"); } else  {     exec sql select pub_name into :pub_name        from publishers where pub_id = :id;    printf("\nPublisher: %s", pub_name);} RENDERAS="SECT3"ID="IN4-261049"Indicator variableswith input variables
Using Indicator Variables with Host Input Variables   REMAP="BO--Body"When you associate an indicator variable with an input variable, you must explicitly set the indicator variable, using the following chart as a guide. TOCENTRY="1"LBL="Table 4-2: "Indicator Variable Values when Used with Input VariableCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="63*"COLNAME="C2" COLWIDTH="261*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ValueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MeaningVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"    -1COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Treat the corresponding input as a null value. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"     0COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Assign the value of the host variable to the column.REMAP="BO--Body"You must supply host language code to test for a null input value and set the indicator variable to -1. This informs Client-Library of a null value. When you set the indicator variable to -1, null is used regardless of the host variable's actual value. REMAP="BO--Body"The following example demonstrates associating an indicator variable with an input variable. The database royalty column is set to a null value because indic is set to -1. Changing the value of indic changes the value of royalty. REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;CS_SMALLINT     indic;CS_INT          royalty;exec sql end declare section; indic = -1;exec sql update titles set royalty = :royalty    :indic where pub_id = "0736";ID="IN4-261050"ConventionsvariableRENDERAS="SECT2"Host Variable Conventions   ID="IN4-261051"Variablesnaming conventionsREMAP="BO--Body"A host variable
ID="IN4-261052"Host variablesnaming
 name must conform to C naming conventions. ID="IN4-261053"Variablesnaming conventionsREMAP="BO--Body"You can use a host variable in an Embedded SQL statement wherever a Transact-SQL literal can be used in a Transact-SQL statement at the same location.REMAP="BO--Body"A host variable must conform to the valid precompiler datatypes. The datatype of a host variable must be compatible with the datatype of the database column values returned. See LINKEND="X23891"Figure 4-1: Datatype Conversions for Result Variables
 and LINKEND="X56060"Figure 4-2: Datatype Conversions for Input Variables
 for details.ID="IN4-261054"Reserved wordsand variable names
ID="IN4-261055"Keywordsand variable namesREMAP="BO--Body" You cannot use host language reserved words and Embedded SQL keywords as variable names.REMAP="BO--Body"A host variable cannot represent Embedded SQL keywords or database objects, except as specified in Dynamic SQL
. For more information on using host variables to represent keywords for database objects, see Chapter 7, "LINKEND="X96546"Using Dynamic SQL
." ID="IN4-261056"Host variablecharacter stringREMAP="BO--Body"When a host variable represents a character string in a   SQL statement, do not place it within quotes. REMAP="BO--Body"The following example is invalid because the precompiler inserts quotes around values when necessary. You should not type in the quotes.REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sqlstrcpy (pub_id, "12345");select pub_id from publisherswhere pub_id like ":pub_id";REMAP="BO--Body"The following example is valid:ID="IN4-251157"Indicator variablesusingREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sqlstrcpy (pub_id, "12345");select pub_id from publisherswhere pub_id like :pub_id;ID="IN4-251158"ArraysusingID="X77536" RENDERAS="SECT1"Using ArraysREMAP="BO--Body"An array is a group of related pieces of data associated with one variable. You can use arrays as output variables for the into clause of MOREINFO="NONE"select and MOREINFO="NONE"fetch statements. REMAP="BO--Body"For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;CS_CHAR  au_array [100] [30];REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql end declare section;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sqlselect au_lnameinto :au_arrayfrom authors;You can fetch a single item anywhere into an array. However, you can only fetch multiple rows into the beginning of an array. REMAP="BO--Body"For details on using arrays with MOREINFO="NONE"select ID="IN4-231359"fetch into
and MOREINFO="NONE"fetch MOREINFO="NONE"into, see LINKEND="K22222""Selecting Multiple Rows via Arrays" in Chapter 6.ID="IN4-231360"Arraysmultiple
ID="IN4-231361"Multiple arraysRENDERAS="SECT2"Multiple ArraysREMAP="BO--Body"When you use multiple arrays within a single SQL statement, they should be the same size. Otherwise, you will receive an error message. ID="IN4-231362"ScopingrulesID="X50057" RENDERAS="SECT1"Scoping RulesREMAP="BO--Body"The precompiler supports the C programming rules for variable scoping. Host variables defined within nested programs can use the ID="IN4-211563"external
external clause plus the variable name. For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"FILE 1:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"CS_CHAR  username[31]main(){    sub1();    printf("%s\n", username);}REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"FILE 2:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"void sub1(){    exec sql begin declare section;    extern char username[31];    exec sql end declare section;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    exec sql select USER() into :username;    return;}ID="IN4-211564"DatatypesC and SQL
ID="IN4-211565"DatatypesC and SQL
ID="IN4-211566"DatatypesID="X23443" RENDERAS="SECT1" DatatypesID="IN4-211567"Datatypes
ID="IN4-211568"Datatypesand declaring variables
ID="IN4-211569"Variablesdeclaring:and datatypes
ID="IN4-211570"Variablesand datatypesREMAP="BO--Body"Host variable datatypes must be compatible with the datatypes of the corresponding database columns. So, before writing your application program, check the datatypes of the database columns. To ensure that your host variables are compatible with the SQL Server datatypes, use the Sybase-supplied typedefs. REMAP="BO--Body"The following table shows and briefly describes the equivalent datatypes. For detailed descriptions of each SQL Server datatype, see the SQL Server Reference ManualID="IN4-211571"Datatypeslist of equivalent
ID="IN4-211572"Datatypeslist of
. TOCENTRY="1"LBL="Table 4-3: "Comparison of C and SQL Server Compatible DatatypesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="99*"COLNAME="C2" COLWIDTH="105*"COLNAME="C3" COLWIDTH="76*"COLNAME="C4" COLWIDTH="73*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Sybase-Supplied 
TypedefCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"DescriptionCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"C Datatype COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SQL Server 
DatatypeVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_BINARYCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Binary typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"unsigned charCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"binary,
varbinaryCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_VARBINARYCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Variable-length 
binary typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"NONECOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_BITCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Bit typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"unsigned charCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"booleanCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_CHARCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Character typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"char[n]COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"char, varcharCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_VARCHARCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Variable-length 
character typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"NONECOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_DATETIMECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"8-byte datetime typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"datetimeCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_DATETIME4COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"4-byte datetime typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"smalldatetimeCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_TINYINTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"1-byte integer typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"unsigned charCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"tinyintCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_SMALLINTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"2-byte integer typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"shortCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"smallintCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_INTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"4-byte integer typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"longCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"intCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_DECIMALCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Decimal typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"decimalCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_NUMERICCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Numeric typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"numericCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_FLOATCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"8-byte float typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"doubleCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"floatCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_REALCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"4-byte float typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"floatCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"realCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_MONEYCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"8-byte money typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"moneyCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_MONEY4COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"4-byte money typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"smallmoneyCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_TEXTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Text typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"unsigned charCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"textCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_IMAGECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Image typeCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"unsigned charCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"imageID="IN4-211573"Datatypesconverting
ID="IN4-211574"Conversion, datatypeRENDERAS="SECT2"Converting Datatypes   REMAP="BO--Body"The precompiler automatically compares the datatypes of host variables with the datatypes of table columns in SQL Server. If the SQL Server datatype and the host language datatype are compatible but not identical, the precompiler converts one type to the other. Datatypes are compatible if the precompiler can convert the data from one type to the other. If the datatypes are incompatible, a conversion error occurs at run time and sqlcode is set to <0. REMAP="BO--Body"Be careful when converting a longer datatype into a shorter one, such as a four-byte into two-byte, because there is always a possibility of truncating data. If a truncation occurs, sqlwarn1 is set to "W".RENDERAS="SECT3"ID="IN4-211575"Datatype conversionsresult variables
Converting Datatypes for Result Variables   ID="IN4-211576"Datatype conversionsresult variables
ID="IN4-211577"Result variablesconverting datatypes for
ID="IN4-211578"Host variableand datatypesREMAP="BO--Body"The following table indicates which data conversions are valid for result variables. A bullet indicates that conversion is possible, but be aware that certain types of errors can result if you are not careful when choosing host variable datatypes.FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig4_1.xwd"LBL="Figure 4-1: " ID="X23891"Datatype Conversions for Result VariablesRENDERAS="SECT3"Converting Datatypes for Input VariablesID="IN4-211579"Datatype conversionsinput variables
ID="IN4-211580"Input variablesconverting datatypes for
ID="IN4-211581"Variablesand datatypes
The following table shows the valid data conversions for input variables. A bullet indicates that conversion is possible. Errors, including truncation, can result if you choose non-convertible host variable datatypes      FLOAT="0"FORMAT="UNKNOWN" FILEREF="fig4_2.xwd"LBL="Figure 4-2: " ID="X56060"Datatype Conversions for Input Variables In the preceding table, * (asterisk) means explicit conversion is required.RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter explained how to declare and use variables, arrays, and datatypes. The next chapter explains how to use statements in an Embedded SQL program to connect to SQL Server.REMAP="BO--Body"NUMBER="5" ID="X18559"Connecting to SQL Server REMAP="BO--Body"This chapter explains how to connect an Embedded SQL program to SQL Server. A connection enables an Embedded SQL program to access a database and perform SQL operations. REMAP="BO--Body"This chapter also describes how to specify servers, user names, and passwords.RENDERAS="SECT1"ID="IN5-3511"Serverconnecting to
Connecting to a Server ID="IN5-3512"SQL Serverconnecting to
ID="IN5-3333"connect
ID="IN5-3334"Databasesaccessing:connecting to SQL ServerREMAP="BO--Body"Use the ID="IN5-3155"connect
MOREINFO="NONE"connect statement to establish a connection between an application program and SQL Server. If an application uses both C and COBOL languages, the first connect statement must be issued from a COBOL program.REMAP="BO--Body"The syntax for the MOREINFO="NONE"connect statement is:ID="IN5-2976"labelvariableREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql connect :user [identified by :password]  [at :connection_name] [using :server] [labelname labelname labelvalue labelvalue...]REMAP="BO--Body"Each of the following sections describes one of the MOREINFO="NONE"connect statement's arguments. Only the user argument is required for the MOREINFO="NONE"connect statement. The other arguments are optional. ID="IN5-2797"userID="X50428" RENDERAS="SECT2"userREMAP="BO--Body"user is a host variable or quoted string that represents a SQL Server user name. The user name must be valid for the server specified. user is a required argument.RENDERAS="SECT2"ID="IN5-25118"password
passwordREMAP="BO--Body"password is a host variable or quoted string that represents the password associated with the user name specified by user. This argument is necessary only if a password is required to access SQL Server. If a password is null, you need not supply password.ID="IN5-23139"connection_nameRENDERAS="SECT2"connection_name ID="IN5-211510"atREMAP="BO--Body"connection_name uniquely identifies the SQL Server connection. It can be a quoted literal. You can create an unlimited number of connections in an application program, one of which can be unnamed. connection_name has a maximum size of 128 characters.ID="IN5-211511"Default serverconnecting toREMAP="BO--Body"When you use connection_name in a MOREINFO="NONE"connect statement, all subsequent Embedded SQL statements that specify the same connection automatically use the server indicated in the MOREINFO="NONE"connect statement. If the MOREINFO="NONE"connect statement specifies no server, the default server is used. See the Open Client/Server Supplement for details on how the default server is determined.To change the current server connection, use the set connection statement described in LINKEND="X54599""Changing the Current Connection" 
.REMAP="BO--Body"An Embedded SQL statement should only reference a connection_name specified in a MOREINFO="NONE"connect statement. At least one MOREINFO="NONE"connect is required for each server that the application program uses.RENDERAS="SECT2"ID="IN5-191712"server
server REMAP="BO--Body"server is a host variable or quoted string that represents a server name. server must be a character string that uniquely and completely identifies a server.RENDERAS="SECT2"labelID="IN5-171913"labelnamevariable
nameREMAP="BO--Body"labelname is only valid with a MOREINFO="NONE"connect statement that is used for B1 Secure Server applications. labelname is not case sensitive. You can have multiple labels, each one referring to a connection to a B1 Secure Server. The labelname and labelvalue clause(s) must be the last clause(s) within the MOREINFO="NONE"connect statement. labelname is either a literal string or a character string host variable.ID="IN5-152114"labelvaluevariableRENDERAS="SECT2"labelvalueREMAP="BO--Body"labelvalue is only valid with a MOREINFO="NONE"connect statement that is used for B1 Secure Server applications. labelvalue is not case sensitive. You can have multiple labels, each one referring to a connection to a B1 Secure Server. The labelvalue and labelname clause(s) must be the last clause(s) within the MOREINFO="NONE"connect statement. labelvalue is either a literal string or a character string host variable.ID="IN5-132315"connectexamplesRENDERAS="SECT2"connect ExampleREMAP="BO--Body"The following example connects to the server "SYBASE" using the password "passes". RENDERAS="SECT3"Connecting to a ServerREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"CS_CHAR user[16]; CS_CHAR passwd[16]; CS_CHAR server[BUFSIZ]; REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql end declare section;  strcpy(server,"SYBASE"); strcpy(passwd,"passes"); strcpy(user, "my_id"); exec sql connect :user identified by :passwd using :server;ID="X54599" RENDERAS="SECT1"Changing the Current ConnectionID="IN5-112516"set connectionREMAP="BO--Body"Use the MOREINFO="NONE"set connection statement to change the current connection. The statement's syntax is as follows:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql set connection {connection_name | default}REMAP="BO--Body"where default is the unnamed connection, if any.REMAP="BO--Body"The following example changes the current connection:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql connect "ME" at connect1 using "SERVER1";exec sql connect "ME" at connect2 using "SERVER2";exec sql set connection connect1;exec sql select userid() into :myid;ID="X90686" RENDERAS="SECT1"Controlling Secure DataREMAP="BO--Body"Use the labelname/labelvalue clauses when writing an Embedded SQL application for a privileged user to connect to a B1 Secure SQL-Server. Check B1 Secure Server documentation for a description of labels and their values.REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql connect "ME" identifed by "my password" using "B1" labelname "current" labelvalue "xxx" labelname "maxwrite" labelvalue "yyy";ID="IN5-112517"Connectionsmultiple
ID="IN5-112518"Multiple connections
ID="IN5-92719"connectand multiple connections
ID="IN5-82820"SQL Servermultiple connections toID="X46747" RENDERAS="SECT1"Establishing Multiple Connections   REMAP="BO--Body"Some Embedded SQL applications require or benefit from having more than one active SQL Server connection. For example: MARK="BULL" REMAP="BU--Bullet"An application that requires multiple SQL Server login names can have a connection for each login account. By connecting to more than one server, an application can simultaneously access data stored on different servers. REMAP="BO--Body"A single application can have multiple connections to a single server or multiple connections to different servers. Use the MOREINFO="NONE"connect statement's MOREINFO="NONE"atMOREINFO="NONE" connection_name clause to name additional connections for an application.REMAP="BO--Body"If you open a connection and then another new named or unnamed connection, the new connection is the current connection.For each Embedded SQL file, the precompiler generates a single file for all stored procedures on all servers. You can load this file into the appropriate server(s). Although the server(s) will report warnings and/or errors about being unable to read the procedures intended for other servers, ignore them. The stored procedures appropriate for each server will load properly on that server. Be sure to load the stored procedures on all applicable servers or your queries will fail.RENDERAS="SECT2"ID="IN5-72921"SQL Servermultiple connections to
ID="IN5-72922"Connectionnaming
Naming a ConnectionREMAP="BO--Body"The following table shows how a connection is named:TOCENTRY="1"LBL="Table 5-1: "How a Connection is NamedCOLS="3" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="115*"COLNAME="C2" COLWIDTH="64*"COLNAME="C3" COLWIDTH="153*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"If this clause is usedCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"But withoutCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Then, the connection name isVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"at connection_nameCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"connection_nameCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"using server_nameCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"atCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"server_nameCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"noneCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"defaultRENDERAS="SECT3"Invalid Statements with the at ClauseREMAP="BO--Body"The following statements are invalid with the MOREINFO="NONE"at clause:REMAP="BO--Body"MOREINFO="NONE"connectbeginMOREINFO="NONE" declareMOREINFO="NONE" sectionendMOREINFO="NONE" declareMOREINFO="NONE" sectionincludeMOREINFO="NONE" fileincludeMOREINFO="NONE" sqlcasetMOREINFO="NONE" connectionwheneverRENDERAS="SECT2"Using SQL Server Connections REMAP="BO--Body"Specify a connection name for any Embedded SQL statement that you want to execute on a connection other than the default unnamed connection. If your application program uses only one connection, you can leave the connection unnamed. Then, you do not need to use theMOREINFO="NONE" at clause.REMAP="BO--Body"The syntax for using multiple connections is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"ID="IN5-53123"at connection_name
exec sql [at connection_name] sql_statement;REMAP="BO--Body"where sql_statement is a Transact-SQL statement.REMAP="BO--Body"The following example shows how two connections can be established to different servers and used in consecutive statements: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"    ...  exec sql begin declare section; CS_CHAR user[16]; CS_CHAR passwd[16]; CS_CHAR name; CS_INT  value, test; CS_CHAR server_1[BUFSIZ]; CS_CHAR server_2[BUFSIZ]; exec sql end declare section;     ... strcpy (server_1, "sybase1"); strcpy (server_2, "sybase2"); strcpy(user, "my_id");strcpy(passwd, "mypass"); exec sql connect :user identified by :passwd      at connection_2 using :server_2; exec sql connect :user identified by :passwd using :server_1;  /* This statement uses the current "server_1"   connection */ exec sql select royalty into :value from authors    where author = :name;  if (value == test) { /* This statement uses connection "connection_2" */     exec sql at connection_2 update authors        set column = :value*2          where author = :name; } ID="X75135" RENDERAS="SECT1"Disconnecting from a ServerREMAP="BO--Body"The connections your application program establishes remain open until you explicitly close them or your program terminates. Use the ID="IN5-33324"disconnect
MOREINFO="NONE"disconnect statement close a connection between the application program and SQL Server. REMAP="BO--Body"The statement's syntax is as follows:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql disconnect {connection_name | current | default | all}REMAP="BO--Body"MOREINFO="NONE"exec sqlID="IN5-13525"disconnect current
MOREINFO="NONE" disconnect current specifies the current connection.REMAP="BO--Body"MOREINFO="NONE"exec sqlID="IN5--13726"disconnect default
MOREINFO="NONE" disconnect default specified the unnamed default connection.REMAP="BO--Body"MOREINFO="NONE"exec sqlID="IN5--33927"disconnect all
MOREINFO="NONE" disconnect all specifies all connections currently in use.REMAP="BO--Body"The MOREINFO="NONE"disconnect statement:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Rolls back the current transactions ignoring any established savepointsCloses the connectionDrops all temporary objects, such as tablesCloses all open cursorsReleases locks established for the current transactionsTerminates access to the server's databasesREMAP="BO--Body"MOREINFO="NONE"disconnectID="IN5--54128"commit
 does not implicitly MOREINFO="NONE"commit current transactions. For more information on using MOREINFO="NONE"disconnect with transactions, see the "Using Transactions" section in Chapter 6.Before the program exits, make sure you perform anMOREINFO="NONE" exec sql disconnect or MOREINFO="NONE"exec sql disconnect all statement for each open connection. In some configurations, SQL-Server may not be notified when a client
 exits without disconnecting. If this happens, resources held by the application will not be released. RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter described how to use the MOREINFO="NONE"connect statement to connect an Embedded SQL program to SQL Server. This connection enables the application program to access a database and perform SQL operations. The chapter also described how to specify servers, user names, and passwords.REMAP="BO--Body"The next chapter explains how to use Transact-SQL with Embedded SQL and host variables. It also describes stored procedures and MOREINFO="NONE"select and MOREINFO="NONE"fetch arrays.REMAP="BO--Body"NUMBER="6" ID="X35507"Using Transact-SQL StatementsID="IN6-3511"Stored proceduresREMAP="BO--Body"This chapter explains how to use Transact-SQL statements with Embedded SQL and host variables. It also explains how to use stored procedures, which are collections of SQL statements stored in SQL Server. Since stored procedures are compiled and saved in the database
, they execute quickly without being recompiled each time you invoke them. RENDERAS="SECT1"ID="IN6-3512"Transact-SQLusing with Embedded SQL
Transact-SQL Statements in Embedded SQL ID="X61832" RENDERAS="SECT2"exec sql SyntaxREMAP="BO--Body"Embedded SQL statements must begin with the keywords MOREINFO="NONE"exec sql and end with the keyword
 MOREINFO="NONE"end-exec. The syntax for Embedded SQL statements is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] sql_statement; REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"connection_name specifies the connection for the statement. See LINKEND="X18559"Chapter 5,  "Connecting to SQL Server," for a description of connections. The MOREINFO="NONE"at keyword is valid for Transact-SQL statements and the MOREINFO="NONE"disconnect statement.sql_statement is one or more Transact-SQL statements. RENDERAS="SECT2"Invalid StatementsID="IN6-3513"Compatibility
ID="IN6-3514"Transact-SQLinvalid keywords in Embedded SQLREMAP="BO--Body"Except for the following four Transact-SQL statements, all Transact-SQL statements are valid in Embedded SQL: ID="IN6-3515"Invalid statmentsprint
MOREINFO="NONE"printID="IN6-3336"Invalid statementsraiserror
MOREINFO="NONE"raiserrorID="IN6-3157"Invalid statementsreadtext
MOREINFO="NONE"readtextID="IN6-2978"Invalid statementswritetext
MOREINFO="NONE"writetextRENDERAS="SECT2"Transact-SQL Statements that Differ in Embedded SQLREMAP="BO--Body"While most Transact-SQL statements retain their functionality and syntax when used in Embedded SQL, the MOREINFO="NONE"select, MOREINFO="NONE"update, and MOREINFO="NONE"deleteID="IN6-2979"DML (Data Manipulation Language)
ID="IN6-29710"Data Manipulation Language (DML)
ID="IN6-27911"into
 statements (the Data Manipulation Language, or DML, statements) can be slightly different in Embedded SQL: MARK="BULL" REMAP="BU--Bullet"The following four items are specific to the MOREINFO="NONE"into clause of the MOREINFO="NONE"select statement. MARK="DASH" REMAP="BS--BulletSub"The MOREINFO="NONE"into clause can assign one row of data to scalar host variables. This is only valid for MOREINFO="NONE"select statements that return just one row of data. If you MOREINFO="NONE"selectID="IN6-231312"SQLCODEand multiple row selects
 multiple rows, a negative SQLCODE results and only the first row is returned.The MOREINFO="NONE"into clause can also specify a table, as in Transact-SQL.If the variables in an MOREINFO="NONE"into clause are arrays, you can MOREINFO="NONE"select multiple rows. If you MOREINFO="NONE"select more rows than the array holds, an exception of SQLCODE <0 is raised and the extra rows are lost.MOREINFO="NONE"select cannot return multiple rows of data in host variables, except through a cursor or by selecting into an array. The MOREINFO="NONE"update and MOREINFO="NONE"delete statements can use the search condition MOREINFO="NONE"where current of MOREINFO="NONE"cursor_name. ID="X95263" RENDERAS="SECT1"Selecting RowsREMAP="BO--Body"There can be a maximum of 256 columns in a MOREINFO="NONE"select statement. For the complete listing of the MOREINFO="NONE"select statement's syntax, see the SQL Server Reference Manual.RENDERAS="SECT2"Selecting One RowID="IN6-211513"selectreturning single rowsREMAP="BO--Body"When you use the MOREINFO="NONE"select statement without a cursor or array, it can only return one row of data. Embedded SQL requires a cursor or an array to return more than one row of data. REMAP="BO--Body"In Embedded SQL, a MOREINFO="NONE"select statement must have an MOREINFO="NONE"into clause. The clause has two functions in Embedded SQL. MOREINFO="NONE"into can specify a list of host variables to be assigned values, or, as in Transact-SQL, it can specify a table.The current Embedded SQL precompiler release does not support into clauses that specify tables. This feature will be added in a future release.REMAP="BO--Body"The syntax of the Embedded SQL MOREINFO="NONE"selectID="IN6-191714"selectsyntax
 statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name]      select [all | distinct] select_list into    :host_variable[[indicator]:indicator_variable]    [, :host_variable     [[indicator]:indicator_variable]...];REMAP="BO--Body"For additional information on MOREINFO="NONE"select statement clauses, see the SQL Server Reference Manual.REMAP="BO--Body"The following MOREINFO="NONE"select statement example accesses the authors table in the pubs2 database and assigns the value of au_id to the host variable ID:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql select au_id into :id from authors      where au_lname = "Stringer"; ID="IN6-191715"ArraysID="K22222" RENDERAS="SECT2"Selecting Multiple Rows Via ArraysREMAP="BO--Body"You can return multiple rows with arrays. The two array actions involve selecting and fetching into arrays.RENDERAS="SECT3"ID="IN6-162016"Arraysselect into
select into ArraysREMAP="BO--Body"Use the MOREINFO="NONE"select into array method when you know the maximum number of rows that will be returned. If a MOREINFO="NONE"select MOREINFO="NONE"into attempts to return more rows than the array can hold, the statement returns the maximum number of rows the smallest array can hold.REMAP="BO--Body"Following is an example of selecting into an array:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;    CS_CHAR titleid_array [100] [6];exec sql end declare section;...exec sql select title_id into :titleid_array    from title_id;[2]REMAP="BO--Body"sqlerrd is an array. The [2] subscript indicates the current row count.RENDERAS="SECT3"Indicator ArraysID="IN6-162017"Arrays
ID="IN6-162018"Indicator arraysREMAP="BO--Body"To use indicators with array fetches, declare an array of indicators of the same length as the host_variable array, and use the syntax for associating the indicator with the host variable. For conventional example:RENDERAS="SECT3"ExampleREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;    int item_numbers [100];    short i_item_numbers [100];exec sql end declare section;...exec sql select it_n from item.info    into :item_numbers :i_item_numbers;...RENDERAS="SECT3"ID="IN6-132319"Batch arraysfetch into
fetch into: ID="IN6-132320"Arrays, batch
Batch ArraysREMAP="BO--Body"MOREINFO="NONE"fetch returns the specified number of rows from the currently active set. Each fetch returns the subsequent batch of rows. For example, if the currently active set has 150 rows and you select and fetch 60 rows, the first fetch returns the first 60 rows. The next fetch returns the following 60 rows. The third fetch returns the last 30 rows.To find the total number of rows fetched, see the SQLERRD field in the SQLCA, as described in LINKEND="X94948""SQL Server SQLCA Variables"
.RENDERAS="SECT3"Cursors and ArraysREMAP="BO--Body"Use the MOREINFO="NONE"fetch MOREINFO="NONE"into array method when you do not know the number of rows to be returned into the array. Declare and open a cursor, then use MOREINFO="NONE"fetch to retrieve groups of rows. If a MOREINFO="NONE"fetch MOREINFO="NONE"into attempts to return more rows than the array can hold, the statement returns the maximum number of rows the smallest array can hold and SQLCODE displays a negative value, indicating that an error or exception occurred.RENDERAS="SECT2"ID="IN6-102621"selectreturning multiple rows
ID="IN6-102622"Cursors
Selecting Multiple Rows Via CursorsREMAP="BO--Body"You can also use cursors to return multiple rows. A cursor
ID="IN6-102623"Current row
 is a data selector that passes multiple rows of data to the host program, one row at a time. The cursor indicates the first row, also called the current row
, of data and passes it to the host program. With the next MOREINFO="NONE"fetch statement, the cursor advances to the next row, which has now become the current row. This continues until all requested rows are passed to the host program. REMAP="BO--Body"Use a cursor when a MOREINFO="NONE"select statement returns more than one row of data. Client-Library tracks the rows SQL Server returns and buffers them for the application. To retrieve data with a cursor, use the MOREINFO="NONE"fetch statement.REMAP="BO--Body"The cursor mechanism is composed of these statements: MARK="BULL" REMAP="BU--Bullet"MOREINFO="NONE"declareMOREINFO="NONE"openMOREINFO="NONE"fetchMOREINFO="NONE"update andMOREINFO="NONE" delete MOREINFO="NONE"where current ofMOREINFO="NONE"closeRENDERAS="SECT3"ID="IN6-102624"Scopingand cursors
ID="IN6-102625"Cursorsand scoping
Cursor Scoping RulesREMAP="BO--Body"The scope of a cursor declaration scope which is the file in which it is declared. The open statement(s) for a cursor must reside in the same file in which the cursor is declared. Once a cursor is open, its scope of is the connection on which it was opened. REMAP="BO--Body"The same cursor name may be opened or multiple connections, and cursor fetch, update, delete, and close operations may occur in files other than the one in which the cursor was declared, as long as they are executed on the same connection on which the cursor was opened. REMAP="BO--Body"Cursor names must be unique within a program. If, at run time, an application attempts to declare two identically named cursors, the application fails. The following error message would result:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"There is already another cursor with the name `XXX'.ID="X22788" RENDERAS="SECT3"ID="IN6-82826"declare cursor
ID="IN6-82827"Cursorsdeclaring
Declaring Cursors   REMAP="BO--Body"Declare a cursor for each MOREINFO="NONE"select statement that returns multiple rows of data. You must declare the cursor before using it, and you cannot declare it within a MOREINFO="NONE"declare section.REMAP="BO--Body"The syntax for declaring a cursor is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql declare cursor_name cursor    for select_statement;REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"cursor_name identifies the cursor. The name must be unique and have a maximum of 30 characters. The name must begin with a letter of the alphabet or with the symbols "#" or "_". select_statement is a MOREINFO="NONE"select statement that can return multiple rows of data. The syntax for MOREINFO="NONE"select is the same as that shown in the SQL Server Reference Manual, except that you cannot use MOREINFO="NONE"into or MOREINFO="NONE"compute clauses. RENDERAS="SECT3"Example: Declaring a CursorREMAP="BO--Body"The following example demonstrates declaring cursors: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql declare c1 cursor forselect type, price from titleswhere type like :wk-type;REMAP="BO--Body"In this example, c1 is declared as a cursor for the rows that will be returned for the type and priceID="IN6-63028"declare cursor
 columns. The precompiler generates no code for the MOREINFO="NONE"declare MOREINFO="NONE"cursor statement. It simply stores the MOREINFO="NONE"select statement associated with the cursor. REMAP="BO--Body"When the cursor opens, the MOREINFO="NONE"select statement or procedure in the MOREINFO="NONE"declare MOREINFO="NONE"cursor statement executes. When the data is fetched, the results are copied to the host variables. Each cursor's MOREINFO="NONE"open and MOREINFO="NONE"declare statement must be in the same file. Host variables used within the MOREINFO="NONE"declare statement must be in scope where the MOREINFO="NONE"open statement is defined. However, once the cursor is open, you can perform MOREINFO="NONE"fetch and MOREINFO="NONE"update/delete MOREINFO="NONE"where current of on the cursor in any file.The declare cursor statement is a declaration, not an executable statement. Therefore, it may appear anywhere in a file; SQLCODE, SQLSTATE, and SQLCA are not set after this statement.RENDERAS="SECT3"ID="IN6-63029"Cursorsopening
ID="IN6-43230"open
Opening Cursors   REMAP="BO--Body"To retrieve the contents of selected rows, you must first open the cursor. The MOREINFO="NONE"open statement executes the MOREINFO="NONE"select statement associated with the cursor in the MOREINFO="NONE"declare statement. The MOREINFO="NONE"open statement's syntax is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql open cursor_name; REMAP="BO--Body"After you declare a cursor, you can open it wherever you can issue a MOREINFO="NONE"select statement. When the MOREINFO="NONE"open statement executes, Embedded SQL substitutes the values of any host variables referenced in the MOREINFO="NONE"declare MOREINFO="NONE"cursor statement's MOREINFO="NONE"where clause.REMAP="BO--Body" The number of cursors you may have open depends on the resource demands of the current session. SQL Server does not limit the number of open cursors. However, you cannot open a currently open cursor. Doing so results in an error message. REMAP="BO--Body"While an application executes, you can open a cursor as many times as necessary, but you must close it before re-opening it. You need not retrieve all the rows from a cursor result set before retrieving rows from another cursor result set.RENDERAS="SECT3"Fetching Data   ID="IN6-33331"Cursorsretrieving data
ID="IN6-33332"Host variablesassigning data to
ID="IN6-13533"fetch REMAP="BO--Body"Use a MOREINFO="NONE"fetch statement to retrieve data through a cursor and assign it to host variables. The syntax for the MOREINFO="NONE"fetch statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name] fetch cursor_name  into :host_variable [[indicator]:indicator_variable][,:host_variable [[indicator]:indicator_variable]...]; REMAP="BO--Body"where there is one host_variable for each column in the result rows. ID="IN6--13734"Host variablesin fetchREMAP="BO--Body"Prefix each host variable with a colon and separate it from the next host variable with a comma. The host variables listed in the MOREINFO="NONE"fetch statement must correspond to SQL Server values that the MOREINFO="NONE"select statement retrieves. Thus, the number of variables must match the number of returned values, they must be in the same order, and they must have compatible datatypes. REMAP="BO--Body"An indicator_variable is a two-byte signed integer declared in a previous MOREINFO="NONE"declare section. If a value retrieved from SQL Server is null, the run-time system sets the corresponding indicator variable to -1. Otherwise, the indicator is set to 0.REMAP="BO--Body"The data that the MOREINFO="NONE"fetchID="IN6--13735"Cursor position
ID="IN6--13736"Current row
ID="IN6--13737"Rowscurrent
 statement retrieves depends on the cursor position. The cursor points to the current row. The MOREINFO="NONE"fetch statement always returns the current row. The first MOREINFO="NONE"fetch retrieves the first row and copies the values into the host variables indicated. Each MOREINFO="NONE"fetch advances the cursor to the next result row.REMAP="BO--Body"Normally, you should place the MOREINFO="NONE"fetchID="IN6--33938"fetch within a loop
 statement within a loop so all values returned by the MOREINFO="NONE"select statement can be assigned to host variables. REMAP="BO--Body"The following loop uses the MOREINFO="NONE"whenever MOREINFO="NONE"not found statement: REMAP="UI--UserInput" FORMAT="LINESPECIFIC"/* Initialize error-handling routines */ REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql whenever sqlerror call err_handle();  exec sql whenever not found goto end_label; for (;;) {     exec sql fetch cursor_name     into :host_variable [, host_variable];     ... } end_label:REMAP="BO--Body"This loop continues until all rows are returned or an error occurs. In either case, sqlcode or sqlstate, which the MOREINFO="NONE"whenever statement checks after each fetch, indicates the reason for exiting the loop. The error-handling routines ensure that an action is performed when either condition arises, as described in 
LINKEND="X73403"Chapter 8,  "Handling Errors."
ID="IN6--94542"selectreturning multiple rows
ID="IN6--44039"Cursorsretrieving data
ID="IN6--44040"Variablesassigning data to
ID="IN6--64241"fetchRENDERAS="SECT3"Using Cursors to Update and Delete Rows
ID="IN6--114743"updatewith cursors
ID="IN6--134944"deletewith cursorsREMAP="BO--Body"To update or delete the current row of a cursor, specify the MOREINFO="NONE"where current of MOREINFO="NONE"cursor_name as the search condition in an MOREINFO="NONE"update or MOREINFO="NONE"delete statement.REMAP="BO--Body"To update rows through a cursor, the result columns to be used in the updates must be "updateable"-they cannot be the result of SQL expressions such as "max(colname)". In other words, there must be a valid correspondence between the result column and the database column to be updated. REMAP="BO--Body"The following example demonstrates how to use a cursor to update rows: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql declare c1 cursor for     select title_id, royalty, ytd_sales     from titles     where royalty < 25;  exec sql open c1;  for (;;) {     exec sql fetch c1 into :title, :roy, :sales;     if (sales > 10000)         exec sql update titles              set royalty = royalty + 2            where current of c1; } exec sql close c1;ID="IN6--155145"update
ID="IN6--175346"updateupdate
ID="IN6--195547"delete
ID="IN6--215748"delete
ID="IN6--215749"Cursorsdeleting current row
ID="IN6--215750"Cursorsupdating current row
ID="IN6--235951"updateprotocolREMAP="BO--Body"The Embedded SQL syntax of the MOREINFO="NONE"update and MOREINFO="NONE"delete statements is the same as in Transact-SQL, with the addition of the MOREINFO="NONE"where MOREINFO="NONE"current of MOREINFO="NONE"cursor_name search condition. REMAP="BO--Body"At run time, an error message is generated and the update is not completed if another user alters the table before your MOREINFO="NONE"update or MOREINFO="NONE"delete statement executes. For details on determining table update protocol and locking, see the SQL Server Reference Manual Volume 2: Stored Procedures.RENDERAS="SECT3"ID="IN6--235952"Cursorsclosing
ID="IN6--256153"close and cursors
Closing Cursors   ID="IN6--276354"close cursorREMAP="BO--Body"Use the MOREINFO="NONE"close statement to clear an open cursor. The syntax for the MOREINFO="NONE"close statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection] close cursor_name; REMAP="BO--Body"To reuse a closed cursor, issue another MOREINFO="NONE"open statement. When you re-open a cursor, it points to the first row. Do not issue a MOREINFO="NONE"closeID="IN6--276355"Cursors
 statement for a cursor that is not open or an error will result. RENDERAS="SECT3"Cursor Example   ID="IN6--276356"CursorsexampleREMAP="BO--Body"The following example shows how to nest two cursors. Cursor c2 depends upon the value fetched into title-id from cursor c1. REMAP="BO--Body"The program gets the value of title-id at open time, not at declare time.REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql include sqlca;  main() {     exec sql begin declare section;     CS_CHAR      title_id[7];     CS_CHAR      title[81];     CS_INT       royalty;     CS_CHAR      au_lname[41];     CS_CHAR      au_fname[21];     exec sql end declare section;     ...     exec sql declare c1 cursor for         select title_id, title, royalty from titles;     exec sql declare c2 cursor for          select au_lname, au_fname from authors          where au_id in             (select au_id from titleauthors              where title_id = :title_id);      exec sql open c1;     for (;;)     {         exec sql fetch c1 into :title_id, :title,             :royalty;        if (sqlca.sqlcode == 100)             break;         printf ("\nTitle ID: %s, Royalty: %d.",              title_id, royalty);         printf("\n%s", title);         if (royalty > 10)         {             exec sql open c2;             for (;;)             {                 exec sql fetch c2 into :au_lname,                        au_fname;                 if (sqlca.sqlcode == 100)                     break;                 printf("\n\ author: %s, %s",                    au_lname, au_fname);             }             exec sql close c2;         }     }     exec sql close c1; } ID="IN6--276357"On-line sample programs
ID="IN6--276358"Documentationon-line
ID="IN6--276359"Sample programson-lineREMAP="BO--Body"See the on-line sample programs for more examples using cursors. For details on accessing the on-line examples, see the Open Client/Server Supplement for your platform. ID="IN6--276360"Stored procedurestypes ofID="K11111" RENDERAS="SECT2"Using Stored ProceduresREMAP="BO--Body"There are two types of ID="IN6--276361"Stored procedures
stored procedures-user-defined and precompiler-generated. Both types run faster than do stand-alone statements because SQL Server preoptimizes the queries. You create user-defined stored procedures and the precompiler generates precompiler-generated stored procedures.RENDERAS="SECT3"User-Defined Stored Procedures   ID="IN6--276362"Stored proceduresand parameters
ID="IN6--276363"Stored proceduresand return status variables
ID="IN6--276364"Stored proceduresexecutingREMAP="BO--Body"When you execute SQL Server stored procedures in Embedded SQL, you can only execute those procedures that contain no MOREINFO="NONE"select statements that return data rows. However, stored procedures can return results to your program in parameters and in a return status variable.REMAP="BO--Body"Stored procedure parameters can be either input or both input and output. For details on stored procedures, see the SQL Server Reference Manual Volume 2.RENDERAS="SECT3"SyntaxID="IN6--276365"$
ID="IN6--276366"_
ID="IN6--276367"#REMAP="BO--Body"Valid stored procedure names consist of upper- and lower-case letters of the alphabet, "$", "_", and "#".REMAP="BO--Body"Do not include the MOREINFO="NONE"useID="IN6--276368"Stored proceduresexecuting
ID="IN6--276369"Stored proceduresexecuting
 statement in a stored procedure. REMAP="BO--Body"To execute a stored procedure, use the following syntax: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec [:status_variable =] procedure_name   [[@parameter_name =] { value | :parameter_variable [[indicator] :indicator_variable] [out[put]]]}...;REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"parameter_nameID="IN6--276370"Binding
 is the name of a variable in the stored procedure. You can pass parameters either by position or by name. If one parameter is named, all must be. For more information on stored procedures, see the SQL Server Reference Manual, Volume 2.ID="IN6--296571"procedure_name
procedure_name is the name of the stored procedure to execute. ID="IN6--316772"status_variable
status_variable can return either a SQL Server return status value or a return code, which either indicates that the stored procedure completed successfully or gives the reasons for the failure. Negative status values are reserved for SQL Server use. See the SQL Server Reference Manual, Volume 2 for a list of return status values for stored procedures. ID="IN6--336973"value
value is a literal constant whose value is passed to the stored procedure.ID="IN6--357174"parameter_variable
parameter_variable is a host variable whose value is passed to the stored procedure.   You can associate an indicator variable with this variable. Note that this variable has no keyword associated with it. All parameters are input.ID="IN6--377375"output
output identifies parameter
 variables which receive new values when the procedure executes.In Embedded SQL, the MOREINFO="NONE"exec keyword is required to execute a stored procedure.You cannot substitute MOREINFO="NONE"execute for MOREINFO="NONE"exec.RENDERAS="SECT3"Stored Procedure ExampleREMAP="BO--Body"The following example shows a call to a stored procedure
 where retcode is a status variable, MOREINFO="NONE"a_proc is the stored procedure, par1 is an input parameter, and par2 is an output parameter: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; CS_INT  par1; CS_INT  par2; CS_SMALLINT  retcode; exec sql end declare section;     ... exec sql exec :retcode = a_proc :par1 out, :par2;RENDERAS="SECT3"ConventionsID="IN6--377376"Nestingstored procedureREMAP="BO--Body"The datatypes of the stored procedure parameters must be compatible with the C host variables. Client-Library only converts certain combinations. See Chapter 4, "LINKEND="X83688""Using Variables"
," for a table of compatible datatypes. RENDERAS="SECT3"Precompiler-Generated Stored ProceduresREMAP="BO--Body"You can set an optional command line switch so the precompiler automatically generates stored procedures that can optimize the execution of Transact-SQL statements in your program. REMAP="BO--Body"For the list of precompiler command line option switches, see the Open Client/Server Supplement for your platform.REMAP="BO--Body"Follow these steps to activate precompiler-generated stored procedures:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Set the appropriate command line switch so the precompiler automatically generates stored procedures for the Transact-SQL statements to be optimized.REMAP="UN--Under"The precompiler generates an ID="IN6--397577"Filesisql
ID="IN6--417778"isql file
MOREINFO="NONE"isql file containing statements that generate the stored procedures. ID="IN6--417779"Interactive SQL
Use interactive SQL (the "MOREINFO="NONE"isql" program) to execute the file. ID="IN6--417780"Output fileREMAP="UN--Under"This loads the stored procedures on SQL Server. The precompiler also creates the stored procedure calls in its output file.REMAP="BO--Body"By default, precompiler-generated stored procedures have the same name as the source program, minus any file extensions. The stored procedures are numbered sequentially and the file name and number are separated by a semicolon (";"). REMAP="BO--Body"For example, the stored procedures for a source program named "test1.pc", its stored procedures would be named "test1;1" through "test1;n", where n is the number of the source program's last stored procedure.REMAP="BO--Body"Optionally, you can set a command line flag that lets you alter the stored procedures' names. By using this flag, you can test a modified application without deleting a stored procedure already in production. After successfully testing the application, you can precompile it without the flag to install the stored procedure. ID="IN6--437981"declare cursorand stored procedures
ID="IN6--458182"Stored proceduresand declare cursorWhen you issue the MOREINFO="NONE"declare cursorID="IN6--498583"select clause
 statement, only the MOREINFO="NONE"select clause is saved as a stored procedure. If an application has syntax errors, the precompiler generates neither the target file nor stored procedures.ID="X29823" RENDERAS="SECT1"Grouping StatementsRENDERAS="SECT2"Via BatchesREMAP="BO--Body"A batch is a group of statements you submit as one unit for execution. The precompiler executes all Transact-SQL statements between the MOREINFO="NONE"exec sql and MOREINFO="NONE"; keywords in batch mode. REMAP="BO--Body"Although the precompiler saves stored procedures, it does not save batches for re-execution. The batch is only effective for the current execution.REMAP="BO--Body"The precompiler only supports batch mode statements that return no result sets.REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql insert into TABLE1 values (:val1)    insert into TABLE2 values (:val2)    insert into TABLE3 values (:val3);REMAP="BO--Body"The three MOREINFO="NONE"insertID="IN6--518784"get diagnosticsand batches
 statements will be processed as a group, which is more efficient than their being processed individually. Use the ID="IN6--538985"get diagnostics
MOREINFO="NONE"get diagnosticsID="IN6--559186"Batchesand get diagnostics
 method of error handling with batches. For details, see LINKEND="X90956""Using get diagnostics"
.REMAP="BO--Body"These statements are legal within a batch because none of them returns results. For more information on batches, see the SQL Server Reference Manual.ID="IN6--559187"Transactions
ID="IN6--579388"TransactionsANSI
ID="IN6--579389"TransactionsISO
ID="IN6--619790"begin transaction
ID="IN6--619791"Triggers
ID="IN6--639992"rollbackin a triggerRENDERAS="SECT2"Via TransactionsREMAP="BO--Body"A transaction
 is a single unit of work, whether the unit is one or 100 statements. The statements in the transaction execute as a group, so either all or none of them execute. REMAP="BO--Body"The precompiler supports two transaction modes-default ANSI/ISOID="IN6--6510193"begin transaction
 and optional Transact-SQL. When you use the optional Transact-SQL mode, you must explicitly commit, save, and roll back transactions. In the Transact-SQL transaction mode, each statement is implicitly committed unless it is preceded by a MOREINFO="NONE"begin transaction statement.REMAP="BO--Body"The Transact-SQL mode uses relatively few system resources, while the default ANSI/ISO transaction mode can dramatically affect system response time. For details on choosing the appropriate mode for your application, see the SQL Server Reference Manual.REMAP="BO--Body"You can use a precompiler option to determine the transaction mode of the connections your application opens. See the Open Client/Server Supplement for details.RENDERAS="SECT3"Transact-SQL Transaction ModeID="IN6--6510194"Transaction modeTransact-SQL
ID="IN6--6510195"Transaction modedefault
ID="IN6--6510196"Default transaction modeREMAP="BO--Body"In this optional Transaction mode, the Embedded SQL syntax is the same as that used in Transact-SQL. The MOREINFO="NONE"begin MOREINFO="NONE"transaction statement initiates transactions. REMAP="BO--Body"The syntax of the Embedded SQL transaction statements is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name]      begin transaction [transaction_name]; REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name]      save transaction [savepoint_name]; REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name] commit transaction      [transaction_name];REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connect_name] rollback transaction      [savepoint_name | transaction_name];MOREINFO="NONE"disconnect rolls back all open transactions. For details on this statement, see Chapter 5, LINKEND="X18559""Connecting to SQL Server"
.REMAP="BO--Body"When you issue a MOREINFO="NONE"begin transaction on a connection, you must also issue a MOREINFO="NONE"save, MOREINFO="NONE"commit, or MOREINFO="NONE"roll back MOREINFO="NONE"transaction on the same connection. Otherwise, an error is generated.RENDERAS="SECT3"ID="IN6--6710397"Transaction ModeANSI
Default ANSI/ISO Transaction Mode   REMAP="BO--Body"ANSI/ISO SQL does not provide a MOREINFO="NONE"save transaction or MOREINFO="NONE"begin MOREINFO="NONE"transaction statement. Instead, transactions begin implicitly when the application program executes one of the following statements:MARK="BULL" REMAP="BU--Bullet"MOREINFO="NONE"deleteMOREINFO="NONE"insertMOREINFO="NONE"selectMOREINFO="NONE"updateMOREINFO="NONE"openMOREINFO="NONE"execID="IN6--6910598"commit workREMAP="BO--Body"The transaction ends explicitly when you issue either a MOREINFO="NONE"commit work or ID="IN6--7110799"rollback work
MOREINFO="NONE"rollback work statement. You must use the ANSI/ISO forms of the MOREINFO="NONE"commit andMOREINFO="NONE" rollback statements. REMAP="BO--Body"The syntax is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql commit [work] end-exec REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql rollback [work] end-exec RENDERAS="SECT2"Extended TransactionsREMAP="BO--Body"An ID="IN6--71107100"Transactionextended
ID="IN6--73109101"extended transaction
extended transaction
 is a unit of work that has multiple Embedded SQL statements. In the Transact-SQL transaction mode
ID="IN6--75111102"begin transaction
, you surround an extended transaction statement with the MOREINFO="NONE"begin transactionID="IN6--77113103"commit transaction
 and MOREINFO="NONE"commit transaction statements. REMAP="BO--Body"In the default ANSI mode, you are constantly within an extended transaction. When you issue a MOREINFO="NONE"commit work statement, the current extended transaction ends and another begins. For details, see the SQL Server Reference Manual.ID="IN6--77113104"Transactionsrestricted statementsUnless the database option "allow MOREINFO="NONE"ddl in tran" is set, do not use the following Transact-SQL statements in an extended, ANSI-mode transaction: MOREINFO="NONE"alter database, create database, create index, create table, create view, disk init, grant, load database, load transaction, reconfigure, revoke, select into table_name, MOREINFO="NONE"truncate table, update statistics.ID="IN6--79115105"rollbackROLLBACKand SQL Server triggersSQL Server triggersRENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter explained how to use Transact-SQL statements with Embedded SQL and host variables. It introduced stored procedures, which are detailed in the SQL Server Reference Manual. The chapter also described how to manipulate multiple data rows via cursors and arrays, and how to use transactions. REMAP="BO--Body"The next chapter explains how and when to use Embedded SQL's advanced programming method, Dynamic SQL.REMAP="BO--Body"NUMBER="7" ID="X96546"Using Dynamic SQL ID="IN7-3511"Dynamic SQLREMAP="BO--Body"This chapter explains Dynamic SQL, an advanced methodology that lets users of Embedded SQL applications enter SQL statements while the application runs. While static SQL will suffice for most of your needs, Dynamic SQL provides the flexibility to build diverse SQL statements at run time. REMAP="BO--Body"Dynamic SQL is a set of Embedded SQL statements that permit online applications to access the database interactively. This interaction with the database lets a user define and execute SQL statements at run time. REMAP="BO--Body"Use Dynamic SQL when one or more of these conditions is not known until run time:MARK="BULL" REMAP="BU--Bullet"SQL statement the user will executeColumn, index, and table referencesHost variable number or datatypeRENDERAS="SECT1"ID="IN7-3512"Dynamic SQLoverview
Dynamic SQL OverviewID="IN7-3333"ANSIand Dynamic SQLREMAP="BO--Body"Dynamic SQL is part of ANSIID="IN7-3334"ISOand Dynamic SQL
 and ISOID="IN7-3335"SQL2 standardand Dynamic SQL
's SQL2ID="IN7-3336"Binding
 standard. It is useful for running an interactive application. If the application only accepts a small set of SQL statements, you can embed them within the program. However, if the application accepts many types of SQL statements, you can benefit from constructing SQL statements, then binding and executing them dynamically.REMAP="BO--Body"The following type of situation benefits from Dynamic SQL. The application program searches a bookseller's database of books for sale. A potential buyer can apply many criteria, including price, subject matter, type of binding, number of pages, publication date, language, and so on. REMAP="BO--Body"A customer might say, "I want a nonfiction book on business that costs between $10 and $20." This request is readily expressed as a Transact-SQL statement: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"select * from titles where      type = "business"     and price between $10 and $20 REMAP="BO--Body"It is not possible to anticipate the combinations of criteria that all buyers will apply to their book searches. Therefore, without using Dynamic SQL, an Embedded SQL program could not easily generate a list of prospective books with a single query. REMAP="BO--Body"With Dynamic SQL, the bookseller can enter a query
 with a different MOREINFO="NONE"where clause search condition for each buyer. The seller can vary requests based on the publication date, book category, and other data, and can vary the columns to be displayed.REMAP="BO--Body"For example:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"select * from titles    where type = ?    and price between ? and ?ID="IN7-3337"Question markand dynamic parameter marker
ID="IN7-3338"? (question mark)dynamic parameter marker
ID="IN7-3339"Dynamic parameter markerREMAP="BO--Body"The question marks ("?") are dynamic parameter markers that represent places where the user can enter search values.ID="X13169" RENDERAS="SECT1"Overview of the Four Dynamic SQL MethodsREMAP="BO--Body"These are the four Dynamic SQL Methods:TOCENTRY="1"LBL="Table 7-1: "Dynamic SQL MethodsCOLS="3" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="72*"COLNAME="C2" COLWIDTH="14*"COLNAME="C3" COLWIDTH="216*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MethodsCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"Syntax VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Method 1COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"execute immediateCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Method 2COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"prepare and MOREINFO="NONE"executeCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Method 3COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"prepare and MOREINFO="NONE"fetchCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Method 4COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"prepare and MOREINFO="NONE"fetch with System DescriptorsID="IN7-32410"Dynamic SQLstatements
ID="IN7-30611"execute immediateDynamic SQL
ID="IN7-30612"StatementsDynamic SQL
ID="IN7-30613"Precompilerand Dynamic SQL statementsMARK="BULL" REMAP="BU--Bullet"Method 1: MOREINFO="NONE"execute immediate. No query is performed, so no data is retrieved. You can execute any Transact-SQL statement that does not return results. The statement is stored in a character string and cannot reference any C program variables. Embedded SQL sends the contents of the character string, unaltered, to SQL Server. The statement executes as many times as the user executes it, but SQL Server parses it each time.ID="IN7-261014"prepare and executeDynamic SQL
ID="IN7-261015"StatementsDynamic SQL
ID="IN7-261016"Precompilerand Dynamic SQL statementsMethod 2: MOREINFO="NONE"prepare and MOREINFO="NONE"execute. Use it in one of two situations:MARK="DASH" REMAP="BS--BulletSub"When no MOREINFO="NONE"select is performed, so no data is retrieved, and you want the statement to execute more than once.To issue a single-row MOREINFO="NONE"select statement which can execute multiple times during the session.You can include descriptors and input variables defined at run time with this method. The statement is stored in a character string and contains dynamic parameter markers to indicate where to substitute the input variables. Embedded SQL substitutes run-time values for the markers just before sending the statement to SQL Server.   ID="IN7-221417"prepare and fetchDynamic SQL
ID="IN7-221418"StatementsDynamic SQL
ID="IN7-221419"Precompilerand Dynamic SQL statementsMethod 3: MOREINFO="NONE"prepare and MOREINFO="NONE"fetch with cursor. This method lets you use a cursor with Dynamic SQL. The cursor is opened, fetched, and closed, as described in 
LINKEND="X35507"Chapter 6, "Using Transact-SQL Statements". You can store the MOREINFO="NONE"select statement in the cursor declaration in a C character string and include dynamic parameter markers for input variables. The markers are replaced with the run-time values of the input variables when the cursor opens. The MOREINFO="NONE"fetch statement is the same as in standard Embedded SQL: you must know the number and datatypes of the columns the MOREINFO="NONE"select statement will return.Method 4: MOREINFO="NONE"prepare and MOREINFO="NONE"fetch with system descriptors. This method lets you use descriptors for varying-list MOREINFO="NONE"select statements. The MOREINFO="NONE"select statement can return a varying, or unpredictable, number and format of data items.REMAP="BO--Body"The following graphic shows when to use each of the four Dynamic SQL methods.         ID="IN7-211520"Dynamic SQLstatementsFLOAT="0"FORMAT="UNKNOWN" FILEREF="fig7_1.xwd"LBL="Figure 7-1: "When to Use Dynamic SQL Methods 1 through 4ID="IN7-211521"Stored proceduresand Dynamic SQL
ID="IN7-211522"Dynamic SQLand stored procedures
ID="IN7-211523"Dynamic SQL protocolRENDERAS="SECT2"Dynamic SQL ProtocolID="IN7-211524"Stored proceduresDynamic SQLThe precompiler does not generate stored procedures for Dynamic SQL statements because the statements are not complete until run time. At run time, SQL Server stores them as temporary stored procedures.REMAP="BO--Body"The Dynamic SQL MOREINFO="NONE"prepareID="IN7-211525"Data Definition Language(DDL)
ID="IN7-211526"DDLData Definition Language
ID="IN7-211527"Data Manipulation Language (DML)
ID="IN7-211528"DMLData Manipulation Language
 statement sends the actual SQL statement, which can be any Data Definition Language(DDL) or Data Manipulation Language (DML) statements, or any Transact-SQL statement except MOREINFO="NONE"create procedure.REMAP="BO--Body"The Dynamic SQL facility performs these actions:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Translates the input data into a SQL statementVerifies that the SQL statement can execute dynamicallyPrepares the SQL statement for execution, sending it to SQL Server, which compiles and saves it as a temporary stored procedure (for methods 2, 3, and 4)Binds all input parameters and descriptors (for methods 2, 3, and 4) Executes the statementMARK="DASH" REMAP="BS--BulletSub"For a varying-list MOREINFO="NONE"select, it uses a descriptor to reference the data items and rows returned (for method 4)Binds the output parameters or descriptor (if method 2, 3,and 4)Obtains results Drops the statement (for methods 2, 3, and 4) by deactivating the stored procedure in SQL ServerHandles all error and warning conditions from SQL Server and Client-LibraryID="IN7-191729"execute immediate
ID="IN7-181830"Dynamic SQLMethod 1ID="X51472" RENDERAS="SECT1"Method 1: Using execute immediate REMAP="BO--Body"Use MOREINFO="NONE"execute immediate to send a complete Transact-SQL statement, stored in a host variable or literal string, to SQL Server. The statement cannot return any results-you cannot use this method to execute a MOREINFO="NONE"select statement. REMAP="BO--Body"The dynamically entered statement executes as many times as the user invokes it during a session. REMAP="BO--Body"With this method, the precompiler:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"Passes the text to SQL ServerVerifies that the statement is not a MOREINFO="NONE"select statementREMAP="BO--Body"Then, SQL Server compiles and executes the statement.REMAP="BO--Body"With MOREINFO="NONE"execute immediate, you can let the user enter all or part of a Transact-SQL statement. REMAP="BO--Body"The syntax for MOREINFO="NONE"execute immediate is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] execute immediate{:host_variable | string};REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"host_variable is a character string variable defined in a MOREINFO="NONE"declare section. Before calling MOREINFO="NONE"execute immediate, the host variable should contain a complete and syntactically correct Transact-SQL statement. string is a literal Transact-SQL statement string that can be used in place of host_variable. REMAP="BO--Body"Embedded SQL sends the statement in host_variable or string to SQL Server without any processing or checking. If the statement attempts to return results or fails, an error occurs. You can test the value of sqlcode after executing the statement or use the MOREINFO="NONE"whenever statement to set up an error handler. See Chapter 8 for information about handling errors in Embedded SQL programs. RENDERAS="SECT2"Method 1: ExamplesREMAP="BO--Body"The following two examples demonstrate using Method 1,MOREINFO="NONE" execute immediate. The first example prompts the user to enter a statement, then executes it: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;     CS_CHAR statement_buffer[linesize]; exec sql end declare section;     ... printf("\nEnter statement\n"); gets(statement_buffer);  exec sql [at connection] execute immediate :statement_buffer; REMAP="BO--Body"The next example prompts the user to enter a search condition to specify rows in the titles table to update. Then, it concatenates the search condition to an MOREINFO="NONE"update statement and sends the complete statement to SQL Server. ID="IN7-171931"Dynamic SQLMethod 1REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;     CS_CHAR sqlstring[200]; exec sql end declare section;  char     cond[150];  exec sql whenever sqlerror call err_p(); exec sql whenever sqlwarning call warn_p();  strcpy(sqlstring,     "update titles set price=price*1.10 where ");  printf("Enter search condition:"); scanf("%s", cond); strcat(sqlstring, cond);  exec sql execute immediate :sqlstring;  exec sql commit;ID="IN7-132332"prepare and executeID="X69351" RENDERAS="SECT1"Method 2: Using prepare and execute ID="IN7-122433"Dynamic SQLMethod 2REMAP="BO--Body"Use Method 2, MOREINFO="NONE"prepare and MOREINFO="NONE"execute, when one of these cases is true:MARK="BULL" REMAP="BU--Bullet"You are certain that no data will be retrieved and you want the statement to execute more than once.AMOREINFO="NONE" select statement returns a single row. With this method, you cannot associate a cursor with the MOREINFO="NONE"select statement.REMAP="BO--Body"This process is also called a single-row MOREINFO="NONE"select. If a user needs to retrieve multiple rows, use method 3 or 4.REMAP="BO--Body"This method uses MOREINFO="NONE"prepare and MOREINFO="NONE"execute to substitute data from C variables into a Transact-SQL statement before sending the statement to SQL Server. The Transact-SQL statement is stored in a character buffer with dynamic parameter markers to show where to substitute values from C variables.REMAP="BO--Body"Because this statement is prepared, SQL Server compiles and saves it as a temporary stored procedure. Then, the statement executes repeatedly, as needed, during the session. REMAP="BO--Body"The MOREINFO="NONE"prepare statement associates the buffer with a statement name and prepares to execute the statement. The MOREINFO="NONE"execute statement substitutes values from a list of C variables or SQL descriptors into the buffer and sends the completed statement to SQL Server. You can execute any Transact-SQL statement this way.ID="X53562" RENDERAS="SECT2"prepareREMAP="BO--Body"The syntax for the MOREINFO="NONE"prepare statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection] prepare statement_name from {:host_variable | string};REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"statement_name is a name up to 128 characters long that identifies the statement. It is a symbolic name or a C character array host variable containing the name of the statements that the precompiler uses to associate an MOREINFO="NONE"execute statement with a MOREINFO="NONE"prepare statement.host_variable is a character array host variable.REMAP="UN--Under"Precede the host variable with a colon, as in standard Embedded SQL statements. string is a literal string that can be used in place of host_variable. host_variable or "string" can contain dynamic parameter markers ("?") which indicate places in the dynamic query where values will ID="IN7-82834"prepare and execute
be substituted when the statement executes.RENDERAS="SECT2"executeREMAP="BO--Body"The syntax for the MOREINFO="NONE"execute statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection] execute statement_name [into host_variable | sql descriptor     descriptor_name][using host_variable :host_variable     [,:host_variable...] | sql descriptor     descriptor_name];REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"statement_name is the name assigned in the MOREINFO="NONE"prepare statement. into is used for a single-row MOREINFO="NONE"select.MOREINFO="NONE"using specifies the C variable substituted for a dynamic parameter marker in host_variable. The variables, which you must define in a MOREINFO="NONE"declare section, are substituted in the order listed. You only need this clause when host_variable contains dynamic parameter markers. descriptor_name represents the area of memory that holds a description of the Dynamic SQL statement's dynamic parameter markers.RENDERAS="SECT2"Method 2: ExampleREMAP="BO--Body"The following example demonstrates using MOREINFO="NONE"prepare and MOREINFO="NONE"execute in Method 2. In this example, the user is prompted to enter a MOREINFO="NONE"where clause that determines which rows in the titles table to update and a multiplier to modify the price. For example, entering "1.1" increases the price by 10%. REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;     CS_CHARsqlstring[200];     CS_FLOAT multiplier; exec sql end declare section;  char   cond[150];  exec sql whenever sqlerror perform err_p(); exec sql whenever sqlwarning perform warn_p();  printf("Enter search condition:"); scanf("%s", cond); printf("Enter price multiplier: "); scanf("%f", &multiplier);  strcpy(sqlstring,     "update titles set price = price * ? where ");ID="IN7-72935"Dynamic SQLMethod 2
strcat(sqlstring, cond);  exec sql prepare update_statement from  :sqlstring;  exec sql execute update_statement using :multiplier; exec sql commit; ID="IN7-63036"Dynamic SQLMethod 3RENDERAS="SECT1"Method 3: Using prepare and fetch with a CursorREMAP="BO--Body"Method 3 uses the MOREINFO="NONE"prepare statement with cursor statements to return results from a MOREINFO="NONE"select statement. Use this method for fixed-list MOREINFO="NONE"select statements that may return multiple rows. That is, use it when the application knows, in advance, the number and type of MOREINFO="NONE"select column list to be returned. You must anticipate and define host variables to accommodate the results. REMAP="BO--Body"When you use Method 3, include the MOREINFO="NONE"declare, MOREINFO="NONE"open, MOREINFO="NONE"fetch, and MOREINFO="NONE"close cursor statements to execute the statement. This is required because the statement returns more than one row. There is an association between the prepared statement identifier and the specified cursor name. You can also include MOREINFO="NONE"updateID="IN7-43237"delete where current of
 and MOREINFO="NONE"delete MOREINFO="NONE"where current of cursor statements.REMAP="BO--Body"As with Method 2, MOREINFO="NONE"prepare and MOREINFO="NONE"execute, a Transact-SQL MOREINFO="NONE"select statement is first stored in a character host variable or string. It can contain dynamic parameter markers to show where to substitute values from input variables. The statement is given a name to identify it in the MOREINFO="NONE"prepare, MOREINFO="NONE"declare, and MOREINFO="NONE"open statements. REMAP="BO--Body"Method 3 requires five steps:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE"MOREINFO="NONE"prepareMOREINFO="NONE"declareMOREINFO="NONE"openMOREINFO="NONE"fetch (and, optionally, MOREINFO="NONE"update and MOREINFO="NONE"delete)MOREINFO="NONE"closeMOREINFO="NONE" REMAP="BO--Body"The following subsections describe these steps.ID="X82813" RENDERAS="SECT2"prepare REMAP="BO--Body"The MOREINFO="NONE"prepare statement is the same as that used with Method 2. For details, see LINKEND="X53562""prepare" 
.RENDERAS="SECT2"declare REMAP="BO--Body"The MOREINFO="NONE"declare statement is similar to the standard MOREINFO="NONE"declare for cursors. The differences are that, in Dynamic SQL, you declare the cursor for a prepared statement_name instead of for a MOREINFO="NONE"select statement, and any input host variables are referenced in the MOREINFO="NONE"open statement instead of in the MOREINFO="NONE"declare statement. REMAP="BO--Body"A dynamic MOREINFO="NONE"declare statement is an executable statement rather than a declaration. As such, it must be positioned in the code where executable statements are legal, and the application should check status codes (SQLCODE, SQLCA, or SQLSTATE) after executing the declaration.REMAP="BO--Body"The Dynamic SQL syntax for the MOREINFO="NONE"declare statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] declare cursor_name      cursor for statement_name;REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"MOREINFO="NONE"atconnection_name specifies the SQL Server connection the cursor will use. cursor_name identifies the cursor, used with the MOREINFO="NONE"open, MOREINFO="NONE"fetch, and MOREINFO="NONE"close statements. statement_name is the name specified in the MOREINFO="NONE"prepare statement, and represents the MOREINFO="NONE"select statement to be executed. RENDERAS="SECT2"open REMAP="BO--Body"The MOREINFO="NONE"open statement substitutes any input variables in the statement buffer, and sends the result to SQL Server for execution. The syntax for the MOREINFO="NONE"open statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] open cursor_name [using {host_var_list | sql descriptor descriptor_name}];REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"cursor_name is the name given to the cursor in the MOREINFO="NONE"declare statement.host_var_list is the name of the host variables that contain the values for dynamic parameter markers.descriptor_name is the name of the descriptor that contains the value for the dynamic parameter markers.RENDERAS="SECT2"fetch and close REMAP="BO--Body"After a cursor opens, the result sets are returned to the application. Then, the data is fetched and loaded into the application program host variables. Optionally, you can update or delete the data. The MOREINFO="NONE"fetch and MOREINFO="NONE"close statements are the same as in standard Embedded SQL. REMAP="BO--Body"The syntax for the MOREINFO="NONE"fetch statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] fetch cursor_nameinto :host_variable [[indicator]:indicator_variable][,:host_variable [[indicator]:indicator_variable]...];REMAP="BO--Body"where: MARK="BULL" REMAP="BU--Bullet"cursor_name is the name given to the cursor in the MOREINFO="NONE"declare statement. There is one C host_variable for each column in the result rows. The variables must have been defined in a MOREINFO="NONE"declare section, and their datatypes must be compatible with the results returned by the cursor. REMAP="BO--Body"The syntax for the MOREINFO="NONE"close statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql[at connection_name] close cursor_name;REMAP="BO--Body"where cursor_name is the name assigned to the cursor in the MOREINFO="NONE"declare statement. RENDERAS="SECT2"Method 3: ExampleREMAP="BO--Body"Following is an example that uses MOREINFO="NONE"prepare and MOREINFO="NONE"fetch, and prompts the user for an MOREINFO="NONE"order by clause in a MOREINFO="NONE"select statement:ID="IN7-33338"Dynamic SQLMethod 3REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section; CS_CHAR     sqlstring[200]; CS_FLOAT    bookprice,condprice; CS_CHAR     booktitle[200]; exec sql end declare section;  char    orderby[150];  exec sql whenever sqlerror call err_p(); exec sql whenever sqlwarning call warn_p();  strcpy(sqlstring, "select title,price from titles where price>? order by ");  printf("Enter the order by clause:"); scanf("%s", orderby); strcat(sqlstring, orderby);  exec sql prepare select_state from :sqlstring; exec sql declare select_cur cursor for select_state;  condprice = 10;  /* the user can be prompted for this value */  exec sql open select_cur using :condprice; exec sql whenever not found goto end;  for (;;) {     exec sql fetch select_cur       into :booktitle,:bookprice;     printf("%20s  %bookprice=%6.2f\n",        booktitle, bookprice); }  end:  exec sql close select_cur; exec sql commit; ID="IN7-23439"Dynamic SQLMethod 4
ID="IN7-23440"System DescriptorID="X58942" RENDERAS="SECT1"Method 4: Using prepare and fetch with System DescriptorsREMAP="BO--Body"This method permits varying-list MOREINFO="NONE"select statements. That is, when you write the application, you need not know the formats and number of items the MOREINFO="NONE"select statement return will return. REMAP="BO--Body"Use this method when you cannot define the host variables in advance because you do not know how many variables are needed or of what type they should be.REMAP="BO--Body"Dynamic SQL Method 4:NUMERATION="ARABIC" REMAP="S1--StepOne" CONTINUATION="RESTARTS" INHERITNUM="IGNORE" Prepares the statement for executionAssociates a cursor with the statementDefines and binds the input parameters or descriptor and:MARK="DASH" REMAP="BS--BulletSub"If using an input descriptor, Method 4 allocates it with the cursor being openedIf using an input parameter, Method 4 associates it with the statementOpens the cursor with the appropriate input parameter(s) or descriptor(s)Allocates the output descriptor if different from the input descriptor and:MARK="DASH" REMAP="BS--BulletSub"Binds the output descriptor to the statementRetrieves the data by using MOREINFO="NONE"fetch cursor and the output descriptorCopies data from system descriptor into host program variablesCloses the cursorDeallocates the descriptor(s)Drops the statement (ultimately, the stored procedure)ID="IN7-23441"System DescriptorusingRENDERAS="SECT2"Using the SQL System DescriptorREMAP="BO--Body"The System Descriptor
ID="IN7-23442"StatementsDynamic SQL
 is an area of memory that holds a description of the variables used in Dynamic SQL statements. Method 4 uses a SQL System Descriptor to handle varying lists of data items. Client-Library manages the System Descriptor. REMAP="BO--Body"You can have one descriptor for input values and another for output (or returned) data items, or one descriptor that provides both functions. When you use Method 4, you must specify the size and number of times these descriptors occur. RENDERAS="SECT3"ID="IN7-23443"System Descriptorproperties
Descriptor PropertiesREMAP="BO--Body"The descriptors contain the following information about the attributes:MARK="BULL" REMAP="BU--Bullet"precision: "0" or an integer. For details, see the Open Client Client-Library/C Reference Manual.scale: integer. For details, see the Open Client Client-Library/C Reference Manual.nullable: "1" (cs_true) if the dynamic parameter can contain nulls; "0" (cs_false) if it cannot. Valid only with MOREINFO="NONE"get descriptor statement.indicator: value for the indicator parameter associated with the dynamic parameter marker. Valid only with MOREINFO="NONE"get descriptor statement.name: name of the dynamic parameter marker. Valid only with MOREINFO="NONE"get descriptor statement.data: value for the dynamic parameter marker specified by the item number. If the value of indicator is -1, the value of data is undefined.count: number of dynamic parameter markers described in the Descriptor.type: datatype of the dynamic parameter marker. Following are the datatypes and equivalent Dynamic SQL codes. For more information, see Chapter 2 of the Open Client Embedded SQL Reference Manual.returned_length: actual length of the data in an output column.ID="IN7-23444"System DescriptorstatementsRENDERAS="SECT2"SQL System Descriptor StatementsREMAP="BO--Body"There are statements that associate the descriptor with a SQL statement and with the appropriate cursor associated with the SQL statement. ID="IN7-23445"StatementsDynamic SQLREMAP="BO--Body"Following is the list of Dynamic SQL statements for Method 4. ID="IN7-03646"allocate descriptor
MOREINFO="NONE"allocate descriptordescribe inputdescribe outputset descriptorget descriptordeallocate descriptorexecuteopen cursorfetch cursorREMAP="BO--Body"For details, see Chapter 2 of the Embedded SQL Reference Manual.REMAP="BO--Body"When a cursor opens, it can have an input descriptor associated with it. The input descriptor contains the values to be substitued for the Dynamic SQL statement's parameter markers.REMAP="BO--Body"Before the cursor is opened, the user fills in the input descriptor with the appropriate information, including the number of parameters, and, for each parameter, its type, length, precision, scale, nullability, indicator, name, and data.REMAP="BO--Body"Associated with the MOREINFO="NONE"fetch statement is an output descriptor, which holds the resultant data. SQL Server fills in the data item's attributes, including its position, type, and the actual data being returned. Use the MOREINFO="NONE"get descriptor statement to copy the data into host variables.ID="IN7--23847"allocate descriptorRENDERAS="SECT2"allocate descriptorREMAP="BO--Body"The MOREINFO="NONE"allocate descriptor statement notifies Client-Library to allocate the SQL System Descriptor. It determines the number of item descriptor areas that SQL Server allocates. If the user does not specify the descriptor's size (number of occurrences), one descriptor is allocated. When this structure is allocated, all of its fields are undefined.REMAP="BO--Body"Following is the MOREINFO="NONE"allocate descriptor statement's syntax:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql allocate descriptor descriptor_name [with max [host_variable | integer_literal]];ID="IN7--44048"set descriptorRENDERAS="SECT2"set descriptorREMAP="BO--Body"Use the MOREINFO="NONE"set descriptor statement to insert or update data in the SQL System Descriptor. The count field is set to the number of dynamic parameter specifications described in the item descriptor area. REMAP="BO--Body"There are two ways to set the descriptor's values. Either use the MOREINFO="NONE"describe statement to designate the system to set the values or use the MOREINFO="NONE"set descriptor statement.REMAP="BO--Body"The syntax for the MOREINFO="NONE"set descriptor statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql set descriptor descriptor_name     {count = host_variable} |     {value item_number {item_name =     :host_variable...}};ID="IN7--64249"get descriptorRENDERAS="SECT2"get descriptorREMAP="BO--Body"The MOREINFO="NONE"get descriptor statement is used to move row or parameter information stored in a descriptor into host variables, thereby allowing the application program to use the information.REMAP="BO--Body"Use the MOREINFO="NONE"get descriptor statement to determine the number of dynamic parameters specified or the number of select list columns of aMOREINFO="NONE" prepare statement. REMAP="BO--Body"The syntax of the MOREINFO="NONE"get descriptor statement is as follows:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql get descriptor descriptor_name     {:host_variable = count} |     {value item_number {:host_variable =    item_name...}};ID="IN7--84450"describe inputRENDERAS="SECT2"describe inputREMAP="BO--Body"The MOREINFO="NONE"describe input statement obtains information about the dynamic parameter marker in the MOREINFO="NONE"prepare statement. The information obtained is the type, and length (or precision and scale, if a number). REMAP="BO--Body"This statement can execute any time after the MOREINFO="NONE"prepare and MOREINFO="NONE"allocate descriptor statements execute. Once this statement executes, the user can compare the information held in the descriptor with what they want to submit via the set descriptor statement. REMAP="BO--Body"The syntax for the MOREINFO="NONE"describe input statement:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql describe input statement_name     using sql descriptor descriptor_name;ID="IN7--104651"describe outputRENDERAS="SECT2"describe outputREMAP="BO--Body"The MOREINFO="NONE"describe output statement obtains information about the select list columns in the MOREINFO="NONE"prepare statement. The user can issue the MOREINFO="NONE"get descriptor statement to access information in the descriptor, and uses the set descriptor statement to modify the information.REMAP="BO--Body"The syntax for the MOREINFO="NONE"describe output statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql describe [ output ] statement_name     using sql descriptor descriptor_name;ID="IN7--124852"deallocate descriptorRENDERAS="SECT2"deallocate descriptorREMAP="BO--Body"The MOREINFO="NONE"deallocate descriptor statement disables the descriptor area.REMAP="BO--Body"The syntax for the MOREINFO="NONE"deallocate descriptor statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql deallocate descriptor descriptor_name;ID="IN7--145053"executeRENDERAS="SECT2"executeREMAP="BO--Body"The MOREINFO="NONE"execute statement executes a previously prepared statement. REMAP="BO--Body"If the prepared statement contains dynamic parameter markers ("?"), the values for these markers are passed in and aligned by position. The using clause defines the host variables into which the actual column values are mapped.REMAP="BO--Body"The syntax for the MOREINFO="NONE"execute statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql [at connection_name] execute statement_name     [into {host_var_list | sql descriptor    descriptor_name}]    [using {host_var_list | sql descriptor    descriptor_name}];ID="IN7--165254"open cursorRENDERAS="SECT2"open cursorREMAP="BO--Body"The MOREINFO="NONE"open cursor statement associates a descriptor with a cursor and opens the cursor.REMAP="BO--Body"The syntax for the MOREINFO="NONE"open cursor statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql open cursor_name     [ using sql descriptor descriptor_ name |    host_var_list]ID="IN7--185455"fetch cursorRENDERAS="SECT2"fetch cursorREMAP="BO--Body"TheMOREINFO="NONE" fetch cursor statement retrieves a row of data for a dynamically declared cursor.REMAP="BO--Body"The syntax for theMOREINFO="NONE" fetch cursor statement is:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql fetch cursor_name     into [host_var_list | sql descriptor    descriptor_name];RENDERAS="SECT2"Method 4: ExampleREMAP="BO--Body"Following is an example that uses MOREINFO="NONE"prepare and MOREINFO="NONE"fetch with dynamic parameter markers.REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section    int  index_colcnt, coltype;    int  int_buff;    char     char_buff[255], void_buff[255];    char type[255], title[255];    char colname[255];    int sales;    int descnt, occur, cnt;    int condcnt, diag_cnt, num_msgs;    char user_id[30], pass_id[30], server_name[30];    char str1[1024], str2[1024], str3[1024],        str4[1024];REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"...void dyn_m4(){ printf("\n\nDynamic sql Method 4\n"); printf("Enter in a Select statement to retrieve    any kind of "); printf("information from the pubs database:"); scanf("%s]", str4);  printf("\nenter in the larger of the columns to    be retrieved or the number "); printf("of ? in the sql statement:\n"); scanf("%d", &occur); exec sql allocate descriptor dinout with max     :occur;exec sql prepare s4 from :str4;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql declare c2 cursor for s4;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql describe input s4 using sql descriptor    dinout;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"fill_descriptor();REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql open c2 using sql descriptor dinout;     into sql descriptor dinoutREMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"while (sqlca.sqlcode != 100 && sqlca.sqlcode >= 0){    exec sql fetch c2 into sql descriptor dinout;    print_descriptor();} exec sql close c2;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql deallocate descriptor dinout;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql deallocate prepare s4;REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"printf("Dynamic SQL Method 4 completed\n\n"); } voidprint_descriptor(){ID="IN7--195556"Dynamic SQLMethod 4REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql get descriptor dinout :descnt = count;printf("Column name \ \ Column data\n"); printf("----------- \ \ -----------------------------------------\n");  for (cnt = 1; cnt <= descnt; cnt++) { /* get each column attribute */    exec sql get descriptor dinout value :index_colcnt :coltype = TYPE;     switch(coltype)    {...     case 4:/* integer type */        exec sql get descriptor dinout value            :index_colcnt                :colname = NAME, :int_buff = DATA;        printf("%s \ \  %d\n", colname, int_buff);        break;...    } } } voidfill_descriptor(){exec sql get descriptor dinout :descnt = count;    for (cnt = 1; cnt <= descnt; cnt++) {    printf("Enter in the data type of the %d ?:",        cnt);    scanf("%d]", &coltype);    switch(coltype)    {...     case 4:/* integer type */        printf("Enter in the value of the data:");        scanf("%d\n", &int_buff);        exec sql set descriptor dinout VALUE :cnt            TYPE = :coltype,                 DATA = :int_buff;            break;      default:        printf("non-supported column type.\n");        break;    } } }RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter described Dynamic SQL, a set of Embedded SQL statements that permit on-line applications to access the database interactively. This interaction with the database lets a user define and execute SQL statements at run time. REMAP="BO--Body"These are the four Dynamic SQL Methods:ID="IN7--215757"execute immediateDynamic SQL
ID="IN7--215758"StatementsDynamic SQL
ID="IN7--215759"Precompilerand Dynamic SQL statementsMARK="BULL" REMAP="BU--Bullet"Method 1: MOREINFO="NONE"execute immediateID="IN7--256160"prepare and executeDynamic SQL
ID="IN7--256161"StatementsDynamic SQL
ID="IN7--256162"Precompilerand Dynamic SQL statementsMethod 2: MOREINFO="NONE"prepare and MOREINFO="NONE"executeID="IN7--296563"prepare and fetchDynamic SQL
ID="IN7--296564"StatementsDynamic SQL
ID="IN7--296565"Precompilerand Dynamic SQL statementsMethod 3: MOREINFO="NONE"prepare and MOREINFO="NONE"fetchMethod 4: MOREINFO="NONE"prepare and MOREINFO="NONE"fetchID="IN7--336966"prepare and fetch with System DescriptorDynamic SQL
ID="IN7--336967"StatementsDynamic SQL
ID="IN7--336968"Precompilerand Dynamic SQL statements
 with System DescriptorsREMAP="BO--Body"The next chapter describes how to detect and correct Embedded SQL errors.REMAP="BO--Body"NUMBER="8" ID="X73403"Handling Errors ID="IN8-3421"Warning- and error-handling routinesREMAP="BO--Body"This chapter discusses how to detect and correct errors that can occur during the execution of Embedded SQL programs. It covers the MOREINFO="NONE"whenever and statement, which you can use to process warnings and errors, and the SQLCA variables that pertain to warnings and errors.REMAP="BO--Body"During the life of an Embedded SQL application, some events may occur that interfere with the application's operation. Some examples are:MARK="DASH" REMAP="BS--BulletSub"The SQL Server becomes inaccessibleThe user enters an incorrect passwordThe user does not have access to a database objectA database object is deletedA column's datatype changesA query returns an unexpected null valueA Dynamic SQL statement contains a syntax errorREMAP="BO--Body"You can anticipate these events by writing warning- and error-handling code to recover gracefully when one of these situations occurs. ID="IN8-3422"Error-testingID="X76976" RENDERAS="SECT1"Testing for Errors   ID="IN8-3333"Errorstesting for
ID="IN8-3154"sqlcodeREMAP="BO--Body"Embedded SQL places a return code in the sqlcode variable to   indicate the success or failure of each SQL statement sent to SQL Server. You can either test the value of sqlcodeID="IN8-2975"whenever
 after each Embedded SQL statement or use the MOREINFO="NONE"whenever statement to instruct the precompiler to write the test code for you. The MOREINFO="NONE"whenever statement is described later in this chapter. ID="IN8-2796"Error-testingand SQLCODE
ID="IN8-25117"sqlcodein error-testing
ID="IN8-23138"SQLCODEand error-testingRENDERAS="SECT2"Using SQLCODEREMAP="BO--Body"The following table lists the values sqlcode can contain: TOCENTRY="1"LBL="Table 8-1: "sqlcode Return Values COLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="72*"COLNAME="C2" COLWIDTH="234*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcode Return Values COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ValueCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Meaning VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"     0COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"No warnings or errorsCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"  <0COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ErrorCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0" 100COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"No rows returned from last statementID="IN8-21159"sqlcodereturn valuesREMAP="BO--Body"When sqlcode is 0, no errors or warnings occurred.REMAP="BO--Body"When sqlcode has a negative value, an error occurred. The sqlca variables contain useful information for diagnosing the error. REMAP="BO--Body"A sqlcode of 100 indicates that there are no result rows, although the statement executed successfully. This is a useful condition for driving a loop that fetches rows from a cursor. When sqlcodeID="IN8-201610"Errorstesting for
 becomes 100, the loop and all rows that have been fetched end. This technique is illustrated in Chapter 6, "LINKEND="X35507""Using Transact-SQL Statements"
". ID="X85292" RENDERAS="SECT1"Testing for Warning ConditionsID="IN8-191711"Warningstesting for
ID="IN8-171912"sqlcode
   REMAP="BO--Body"Even if sqlcode indicates that a statement executed successfully, a warning condition may still have occurred. sqlca.sqlwarn is an eight-character array that indicates various warning conditions. REMAP="BO--Body"sqlwarn[0] contains a "W" if a warning condition occurred, and a space, otherwise. If sqlwarn[0] contains a "W", look for a "W" in one of the other ID="IN8-152113"sqlwarn
sqlwarn array elements.REMAP="BO--Body"Test for a warning after you determine that a SQL statement executed successfully. Use the MOREINFO="NONE"whenever statement, as described in the next section, to instruct the precompiler to write the test code for you. ID="IN8-132314"sqlwarn
ID="IN8-112515"sqlwarnflagsREMAP="BO--Body"The following table describes the conditions that set each flag: TOCENTRY="1"LBL="Table 8-2: "sqlwarn Flags COLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="81*"COLNAME="C2" COLWIDTH="279*"VALIGN="BOTTOM"COLNAME="C1" NAMEST="C1" NAMEEND="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"sqlwarn Flags COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FlagCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Description VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[0]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"If blank, no error occurred. If "W", a warning condition 
occurredCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[1]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"A character string transferred from SQL Server to a host 
variable was truncatedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[2]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ReservedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[3]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"There are fewer columns in a MOREINFO="NONE"select than the number of host 
variables in the MOREINFO="NONE"into clauseCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[4]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ReservedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[5]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ReservedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[6]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ReservedCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarn[7]COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ReservedRENDERAS="SECT1"Trapping Errors with whenever   REMAP="BO--Body"Use the Embedded SQL MOREINFO="NONE"whenever statement to trap errors and warning conditions. It specifies actions to be taken depending on the outcome of each Embedded SQL statement sent to SQL Server. REMAP="BO--Body"The MOREINFO="NONE"whenever statement is not executable. Instead, it directs the precompiler to generate C code that tests for specified conditions after each executable Embedded SQL statement in the program.REMAP="BO--Body"The syntax of the MOREINFO="NONE"whenever statement is: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql whenever {sqlwarning | sqlerror | not found} {continue | goto label |  call function_name ([param [, param]...]) | stop}; ID="IN8-33320"whenevertesting conditions
ID="IN8-13521"Testing conditionswheneverID="X94251" RENDERAS="SECT2"whenever Testing ConditionsREMAP="BO--Body"Each MOREINFO="NONE"whenever statement can test for one of the following three conditions:MARK="BULL" REMAP="BU--Bullet"MOREINFO="NONE"sqlwarningMOREINFO="NONE"sqlerrorMOREINFO="NONE"not foundID="IN8-13522"Listing fileREMAP="BO--Body"The precompiler generates warning messages if you do not write a MOREINFO="NONE"whenever ID="IN8--33923"whenever...continue
statement for each of the three conditions. If you write your own code to check for errors and warnings, suppress the precompiler warnings by writing a MOREINFO="NONE"whenever...continue clause for each condition. This instructs the precompiler to ignore errors and warnings. ID="IN8--33924"FileslistingREMAP="BO--Body"If you precompile with the verbose option, the precompiler generates a ct_debug() function call as part of each MOREINFO="NONE"connect statement. This causes Client-Library to display informational, warning, and error messages to your screen as your application runs. The MOREINFO="NONE"whenever statement does not disable these messages. For more information on the precompiler options, see the Open Client/Server Supplement for your platform.REMAP="BO--Body"After an Embedded SQL statement executes, the values of sqlcode and sqlwarn0 determine if one of the conditions exists. The following table shows the criteria MOREINFO="NONE"whenever uses to detect the conditions: TOCENTRY="1"LBL="Table 8-3: "Criteria for the whenever Statement COLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="99*"COLNAME="C2" COLWIDTH="180*"VALIGN="BOTTOM"COLNAME="C1" NAMEST="C1" NAMEEND="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"Criteria for the whenever StatementCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"ConditionCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"CriteriaVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlwarningCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcode = 0 and sqlwarn[0] = "W" COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlerrorCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcode < 0 COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"not foundCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"sqlcode = 100 REMAP="BO--Body"To change the action of a MOREINFO="NONE"whenever statement, write a new MOREINFO="NONE"whenever statement for the same condition. MOREINFO="NONE"whenever applies to all Embedded SQL statements that follow it, up to the next MOREINFO="NONE"whenever statement for the same condition. REMAP="BO--Body"The MOREINFO="NONE"whenever statement ignores the application program's logic. For example, if you place MOREINFO="NONE"whenever at the end of a loop, it does not affect the preceding statements in subsequent passes through the loop.ID="IN8--54125"wheneverRENDERAS="SECT2"whenever ActionsID="IN8--64226"ErrorstrappingREMAP="BO--Body"The MOREINFO="NONE"whenever statement specifies one of the following four actions: TOCENTRY="1"LBL="Table 8-4: "whenever ActionsCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="81*"COLNAME="C2" COLWIDTH="279*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"whenever ActionsCOLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"ActionCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"Description VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"continue COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Perform no special action when a SQL statement returns the 
specified condition. Normal processing continues. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"goto COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Perform a branch to an error handling procedure within 
your application program. You can write MOREINFO="NONE"goto as either 
"MOREINFO="NONE"goto" or "MOREINFO="NONE"go to", and you must follow it with a valid 
statement label name. The precompiler does not detect an 
error if the label name is not defined in the program, but the 
C compiler does. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"call COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0" Call another C routine and, optionally, pass variables.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"stopCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Terminate the program when a SQL statement triggers the 
specified condition.ID="IN8--84427"get diagnosticsusingID="X90956" RENDERAS="SECT1"Using get diagnosticsREMAP="BO--Body"The MOREINFO="NONE"get diagnostics statement retrieves error, warning, and informational messages from Client-Library. It is similar to, but more powerful than, the MOREINFO="NONE"whenever statement because you can expand it to retrieve more details of the detected errors. REMAP="BO--Body"If, within a MOREINFO="NONE"whenever statement, you specify the application to go to or call another routine, specify MOREINFO="NONE"get diagnostics in the function code, as follows:REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"voiderror_handler(){      exec sql begin declare section;        int num_msgs;        int condcnt;    exec sql include sqlca;    exec sql end declare section;    exec sql get diagnostics :num_msgs = number;    for (condcnt=1; condcnt <= num_msgs; condcnt++)    {        exec sql get diagnostics exception :condcnt            :sqlca = sqlca_info;        printf("sqlcode is :%d\n\ message text:            %s\n", sqlca.sqlcode,            sqlca.sqlerrm.sqlerrmc);    }}ID="IN8--94528"Routineserror- and warning-handling
ID="IN8--104629"Warning- and error-handling routines
ID="IN8--104630"Error handlerwriting
ID="IN8--104631"Warning handlerwriting
ID="IN8--104632"Handlerserror and warningID="X68800" RENDERAS="SECT1"Writing Routines to Handle Warnings and Errors   ID="IN8--104633"Error-handlingroutines
ID="IN8--104634"Warning-handling routinesREMAP="BO--Body"A good strategy for handling errors and warnings in an Embedded SQL application is to write custom procedures to handle them, then install the procedures with the MOREINFO="NONE"whenever...MOREINFO="NONE"call statement. ID="IN8--124835"warning_hndlREMAP="BO--Body"The following example shows sample warning and error handling routines. For simplicity, both routines omit certain conditions that should normally be included. MOREINFO="NONE"warning_hndl omits the code for sqlwarnID="IN8--145036"error_hndl
[1]. MOREINFO="NONE"error_hndl omits the code that handles Client-Library errors and operating system errors: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"/* Declare the sqlca.  */exec sql include sqlca;exec sql whenever sqlerror call error_handler();exec sql whenever sqlwarning call     warning_handler();exec sql whenever not found continue;/*** void error_handler()**** Displays error codes and numbers from the sqlca/*void error_handler(){    fprint(stderr,     "\n**sqlcode=(%d)",sqlca.sqlcode); /*** void warning_handler()****  Displays warning messages.*/void warning_handler(){     if (sqlca. sqlwarn[1] == `W')    {        fprintf(stderr, "\n** Data truncated.\n");    }     if (sqlca.sqlwarn[3] == `W')    {        fprintf(stderr, "\n** Insufficient            host variables to store results.\n");    }    return;}ID="IN8--155137"Routineserror- and warning-handling
ID="IN8--155138"Precompiler-Detected Errors
ID="IN8--155139"Errorsprecompiler-detected
ID="IN8--155140"PrecompilerdiagnosticsID="X73758" RENDERAS="SECT1"Precompiler-Detected Errors   ID="IN8--155141"Embedded SQL statementssyntax-checking
ID="IN8--155142"Syntax checkingof Embedded SQL statementsREMAP="BO--Body"The Embedded SQL precompiler detects Embedded SQL errors at precompile time. The precompiler detects syntax errors such as missing semicolons and undeclared host variables in SQL statements. These are severe errors, so appropriate error messages are generated. REMAP="BO--Body"You can also have the precompiler check Transact-SQL syntax errors. SQL Server parses Transact-SQL statements at precompile time if the appropriate precompiler command options are set. See the precompiler reference page in the Open Client/Server Supplement for your platform.ID="IN8--155143"Parse
ID="IN8--155144"Errorsfailure to detect:exampleREMAP="BO--Body"The precompiler does not detect the error in the following example, in which a table is created and data is selected from it. The error is that the host variables' datatypes do not match the columns retrieved. The precompiler does not detect the error because the table does not yet exist when the precompiler parses the statements: REMAP="CO--ComputerOutput" FORMAT="LINESPECIFIC"exec sql begin declare section;  CS_INT   var1;  CS_CHAR  var2[20]; exec sql end declare section;  exec sql create table    T1 (col1 int, col2 varchar(20)); ....  exec sql select * from T1 into :var2, :var1;REMAP="BO--Body"Note that the error will be detected and reported at run time.RENDERAS="SECT1"SummaryREMAP="BO--Body"This chapter described methods of detecting and correcting errors that occur during execution of Embedded SQL program execution. It introduced the MOREINFO="NONE"get diagnostics and MOREINFO="NONE"whenever statements designed for error handling.REMAP="BO--Body"NUMBER="A" ID="X85720"Precompiler Warning and Error MessagesREMAP="BO--Body"The Embedded SQL precompiler generates the informational, warning, and error messages in the following nine tables. The first seven tables document messages you can receive during the precompilation process. The eighth table, LINKEND="X65166"Table A-8: Run-Time Messages
, documents messages you can receive during run time, after your application has compiled successfully.REMAP="BO--Body"Each table contains four fields.MARK="BULL" REMAP="BU--Bullet"The first field, "Message_ID," lists the identification number of the message you may receive.The second field, "Message Text," lists the on-line text associated with the message you may receive.The third field, "Severity," lists the seriousness of with the message you may receive. A message can be:MARK="DASH" REMAP="BS--BulletSub"Informational-No error or warning was detected, and the precompiler succeeded. The message is purely informational.Warning-A non-critical error was detected, but the program precompiled.Severe-An error occurred, and no code was generated. The precompilation failed.Fatal-A severe error occurred from which the precompiler cannot recover. No further attempt will be made to process your files. Precompiler exits.REMAP="BO--Body"The fourth field, "Fix," a suggests a means of correcting the situation that caused the error or warning.TOCENTRY="1"LBL="Table A-1: "Command Line Option MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="115*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" NAMEST="C1" NAMEEND="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"Command Line Option MessagesCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE TEXTCOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_DUPOPTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Duplicate 
command line 
option specified.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Do not duplicate the 
options specified on the 
command line remove the 
offending duplicate option.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_INVLD_HLANGCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Host Language 
specified is invalid.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Valid options are ANSI_C, 
COB_MF1, COB_MF2, 
COB_RM1, COB_RM2, 
COB_LPI, COB_VAXVMS, 
ADA_C, FORTRAN_C, 
FORTRAN77_C, PL1_C, 
KR_C.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_INVLD_OCLIB_VERCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The Open Client 
Client Library 
version is invalid.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The correct version string is 
"CS_VERSION_100".COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_INVOPTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Option is invalid.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Invalid option specified. 
Substitute the correct value.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_MSGINIT_FAILCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error initializing 
localized error 
messages.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the Sybase 
installation is complete and 
that there is a valid entry for 
the LANG variable in the 
locales.dat file.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_MULTI_IN_USE_DEF_OUTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"When 
precompiling 
multiple input 
files, you cannot 
specify output 
(Listing, SQL, or 
Language) file 
names.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Remove all "-G", "-L", and 
"-O" flags from the 
command line or 
precompile the files one at a 
time.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPEN_INCLUDECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to open the 
specified include 
file <file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The specified file is either 
not in the path or is missing 
the required read 
permission. Specify the path 
with the "I" flag and verify 
the read permission.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPEN_INPUTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to open the 
specified input file 
<file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the validity of the 
path and filename specified. 
If the filename extension is 
not provided, the 
precompiler searches for the 
default extension.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPEN_ISQLCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to open the 
specified ISQL file 
<file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the validity of the 
ISQL filename (the file in 
which the stored 
procedures are written). 
Verify that you have the 
write permission in the 
directory where the file is 
being created.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPEN_LISTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to open the 
specified listing file 
<file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the validity of the 
listing filename. Verify that 
you have write permission 
in the directory where the 
file is being created.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPEN_TARGETCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to open the 
specified target file 
<file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the validity of the 
output filename. Verify that 
you have write permission 
in the directory where the 
file is being created.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_NO_INPUT_FILECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: No input file 
is specified to be 
precompiled.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Specify an input file for 
precompilation.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPT_REINITCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning: switch 
initialized multiple 
times.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The specified switch has 
been initialized multiple 
times. The second and 
subsequent values are 
ignored.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_PATH_OFLCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: Max allowed 
paths for 
"INCLUDE" files is 
64 (OVERFLOWED).COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The maximum allowed 
paths on the command line 
have been exceeded. 
Reduce the number of 
directories from where the 
"INCLUDE" files are fetched.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_STATIC_HV_CNAMECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Static cursor names 
cannot be host-
variables: <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Replace the host variable 
with a SQL identifier.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNBALANCED_DQCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unbalanced quotes 
in delimited 
identifier.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Balance the quote.TOCENTRY="1"LBL="Table A-2: "First Pass Parser MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"First Pass Parser MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_CONST_FETCHCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: Attempted 
fetch into CONST 
storage class 
variable <value>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"You cannot fetch into a 
constant type. To fetch the 
value, remove the constant 
qualifier in its declaration.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_DUP_HVCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Duplicate host 
variable in <file> at 
line <line number>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Another host variable with 
the same name is already 
declared in the same block. 
Verify that each variable 
within a given block has a 
unique name.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_DUP_STRUNIONCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Duplicate 
structure/union in 
<file> at <line 
number>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Another structure with the 
same name is already being 
declared in the same block. 
Verify that each variable 
within a given block has a 
unique name.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_IDENT_OR_STRINGVARCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: item must be 
a SQL-identifier or 
a string-type 
variable.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the connection, 
cursor, or statement name is 
of type string or SQL 
identifier.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_ILL_LITERALCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Use of literal value 
at illegal place.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Do not use a literal value in 
the specified location.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_ILL_LITERAL_USAGECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Use of literal 
parameters to an 
RPC with an 
OUTPUT qualifier.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Do not use a literal as an 
OUTPUT parameter to a 
stored procedure.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_ILL_PARAM_MODECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: Mixing 
calling modes in an 
RPC call in <file> at 
<line number>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Call the stored procedure 
with arguments passed by 
name or by position. Mixing 
these modes in the same call 
is illegal. COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_MULTIDIM_ARRAYCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: at <line>. 
Multiple-
dimensioned array 
variables are not 
supported.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Multiple-dimensioned 
arrays are not supported. 
Break up a mxn array into m 
arrays of n elements each.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_NODCL_NONANSICOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning: Neither 
SQLCODE nor 
SQLCA declared in 
non-ANSI mode.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"In non-ANSI mode, declare 
either SQLCA, SQLCODE, or 
both. Verify that the scope is 
applicable for all Embedded 
SQL statements within the 
program.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_NOT_AT_ABLECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0""AT" clause cannot 
be used with 
statement type 
<value>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Remove the "AT" clause 
from the specified 
statement.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_NUMBER_OR_INTVARCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: item must be 
an integer constant 
or an integer type 
variable.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unused. May be used to 
raise an error if some field 
in the Dynamic SQL 
statements (e.g., MAX, 
Value <n>,) are not an 
integer type or an integer 
constant.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_PASS1_ERRCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"File <file>: Syntax 
errors in Pass 1: 
Pass 2 not done.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Errors in Pass 1 resulted in 
an aborted precompilation. 
Correct Pass 1 errors, then 
proceed.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_QSTRING_OR_STRINGVA
RCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error: item must be 
a quoted string or a 
type string variable.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that server name, 
user name, and password 
are either double-quoted 
strings or of type string.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_SQLCODE_UNDCLCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning: SQLCODE 
not declared while 
in ANSI mode.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"In ANSI mode, declare 
SQLCODE in the DECLARE 
SECTION.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_STRUCT_NOTFOUNDCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Structure/union 
definition not 
found in scope in 
<file> at <line 
number>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the definition of 
the structure or union is 
within the scope of the 
program.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_SYNTAX_YACCCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Syntax error in file 
<file> at <line 
number>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the indicated line 
number for a syntax error in 
the Embedded SQL 
grammar.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNBALANCED_DQCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unbalanced quotes 
in delimited 
identifier.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Balance the quotes.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNDEF_ELMCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error <value>: 
illegal structure/ 
union element.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The specified element of the 
structure is not included in 
the structure definition. 
Correct the definition.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNDEF_HVCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Host variable 
<value> undefined.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Define the host variable in 
the proper place.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNDEF_IVCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Indicator variable 
<value> undefined.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Define the indicator 
variable in the proper place.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNDEF_STRCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error structure 
<value> undefined.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Undefined structure on the 
specified line. Define the 
structure in the proper 
scope.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_UNSUPCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The <value>, feature 
is not supported in 
this release.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"This feature is not 
supported.TOCENTRY="1"LBL="Table A-3: "Second Pass Parser MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Second Pass Parser MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_CURS_RDCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The cursor <value> 
is redefined at 
<line number> in 
<file>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"A cursor with same name 
has already been declared.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_HOSTVAR_MULTIBINDCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning: host 
variable used as a 
bind variable 
<value> more than 
once per statement.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Do not use a host variable 
multiple times in a single 
fetch statement. You cannot 
fetch multiple results into 
one location. Client Library 
causes the last value fetched 
to be put in the variable.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_INVTYPE_IVCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Indicator variable 
is an incorrect type.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The indicator variable 
should be of type 
CS_SMALLINT or of type 
INDICATOR.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_PARSE_INTERNALCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Internal parser 
error at <line>. 
Please contact a 
Sybase 
representative.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Immediately report this 
internal consistency parser 
error to Sybase Technical 
Support.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_WHEN_NFCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to find the 
SQL statement 
"WHENEVER NOT 
FOUND".COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Enter a "WHENEVER NOT 
FOUND" statement.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_WHEN_WARNCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to find the 
SQL statement 
"WHENEVER 
WARNING".COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Enter a "WHENEVER 
WARNING" statement.TOCENTRY="1"LBL="Table A-4: "Code Generation MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Code Generation MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_WRITE_TARGETCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to write to 
the target file. 
Return code: 
<value>.COLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unable to write to the 
Target file. Verify your 
permission to create and 
write to a file in the 
directory where the 
precompiler is generating 
the target file. Also, verify 
that the file system is not 
full.TOCENTRY="1"LBL="Table A-5: "FIPS Flag MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS Flag MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_ARRAYCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension ARRAY 
type at <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. ANSI extension for 
using arrays.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_DATAINITCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension Data 
Initialization at 
<line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. ANSI extension for 
data initialization.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_HASHDEFCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension 
"#DEFINE" <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. ANSI extension for 
using "#DEFINES" in a 
DECLARE SECTION.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_LABELCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension ':' with 
label in a 
"WHENEVER" 
clause.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. ANSI extension for 
allowing ":" with a label in a 
"WHENEVER" clause.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_POINTERCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension POINTER 
type at <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. The type POINTER is 
an ANSI extension.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_SYBTYPECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension Sybase 
SQL-Type <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. ANSI extension for 
using SYBASE-specific 
datatypes.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_TYPECOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension data type 
at <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. The specified syntax 
is not ANSI compliant.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_TYPEDEFCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension TYPEDEF 
<line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. The TYPEDEF is an 
ANSI extension.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FIPS_VOIDCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FIPS-flagger 
Warning: ANSI 
extension VOID 
type <line>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"None. The type VOID is an 
ANSI extension.TOCENTRY="1"LBL="Table A-6: "Internal Error MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Internal Error MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_FILE_STACK_OVFLCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"File stack overflow: 
Max allowed 
nesting is <value>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The file stack overflowed 
while trying to process the 
nested INCLUDE statement. 
Do not exceed the nested 
depth maximum of 32.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_INTERNAL_ERRORCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Fatal Internal Error 
at <file> <line>: 
Argument 
inconsistency error. 
Please contact 
Sybase 
representative.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"This is an internal error. 
Contact your Sybase 
representative.TOCENTRY="1"LBL="Table A-7: "SYBASE and Client-Library MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="151*"COLNAME="C2" COLWIDTH="100*"COLNAME="C3" COLWIDTH="79*"COLNAME="C4" COLWIDTH="136*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SYBASE and Client-Library MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE_IDCOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGECOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_COLMCNTCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The bind count of 
the <bind variable 
count> and the 
column count of 
result set are 
incompatible.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The number of returned 
columns is different from 
the number of results 
columns returned with the 
bind variable types and 
number.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_COLVARLMCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The host variable 
<name> length 
<value> is less than 
the column length 
of <value>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The host variable may not 
be able to hold the fetched 
column. Check the column 
length and adjust the length 
of the host variable, 
accordingly.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_COLVARPSCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The host variable 
<name> precision 
and scale: <value> 
are different from 
the column's 
precision <value> 
and scale: <value> COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"The precision and scale of 
the host variable is different 
from that of the column 
being fetched or inserted 
into. Make the scale and 
precision compatible.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_COLVARTMCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Open Client unable 
to convert type 
<value> to type 
<value> for host 
variable name.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Illegal type. Use MOREINFO="NONE"cs_convert, 
as Open Client will not 
convert by default.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OCAPICOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Error during 
execution of the 
Open Client API 
<value>. Error: 
<value>.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Warning COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Depending on the context in 
which this warning occurs, 
you may be required to take 
corrective action before 
proceeding.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_OPERSYSCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Operating system 
error: <value> 
occurred during 
execution of the 
Open Client API.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"An Operating System error 
occurred. Speak with the 
Systems Administrator.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"M_SYBSERVCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Sybase Server 
error. Server: 
<value>. Message: 
name.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"WarningCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Check the syntax of the 
statement sent to the Server 
which caused this error. 
Verify that all resources are 
available in the Server to 
process the SQL statement.TOCENTRY="1"LBL="Table A-8: " ID="X65166"Run-Time MessagesCOLS="4" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="93*"COLNAME="C2" COLWIDTH="158*"COLNAME="C3" COLWIDTH="75*"COLNAME="C4" COLWIDTH="140*"VALIGN="BOTTOM"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Run-Time MessagesCOLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SQLCODE VALUE,
SQLSTATE CODECOLNAME="C2" ALIGN="CENTER" ROTATE="0" MOREROWS="0"MESSAGE TEXTCOLNAME="C3" ALIGN="CENTER" ROTATE="0" MOREROWS="0"SEVERITYCOLNAME="C4" ALIGN="CENTER" ROTATE="0" MOREROWS="0"FIXVALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25001
ZZ000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unrecoverable error occurred.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Immediately report this 
error to Sybase Technical 
Support.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25002
ZA000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Internal error occurred.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"FatalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Immediately report this 
error to Sybase Technical 
Support.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25003
ZD000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected 
CS_COMPUTE_RESULT received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentations for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25004
ZE000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected CS_CURSOR_RESULT 
received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentations for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25005
ZF000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected CS_PARAM_RESULT 
received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentations for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25006
ZG000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected CS_ROW_RESULT 
received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentations for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25007
ZB000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"No message(s) returned for 
SQLCA, SQLCODE, or SQLSTATE.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"InformationalCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Informational message. No 
action is required.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25008
ZC000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Connection has not been defined 
yet.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Enter a valid MOREINFO="NONE"connect 
statement.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25009
ZH000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected CS_STATUS_RESULT 
received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentations for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25010
ZI000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unexpected 
CS_DESCRIBE_RESULT received.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that the value 
returned by the CS_LIBRARY 
routine is valid. Consult 
your CS-Library 
documentation for details.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25011
22005COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Data exception-error in 
assignment of item descriptor 
type.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Enter a valid descriptor type. 
Valid types are:COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25012
ZJ000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Memory allocation failure.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"There is an insufficient 
amount of memory to 
allocate to this operation.COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"25013
ZK000COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SQL-Server must be version 10 
or greater.COLNAME="C3" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SevereCOLNAME="C4" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Verify that your installation 
has an installed, functioning 
copy of SQL Server 10.0 or 
higher. If you do not have 
SQL Server 10.0 or higher, 
have your installation's 
designated person contact 
the Technical Support 
Center.REMAP="BO--Body"REMAP="BO--Body"NUMBER="B" ID="X43986"Typedefs and LimitsID="INB-3511"TypedefsRENDERAS="SECT1"RENDERAS="SECT2"TypedefsREMAP="BO--Body"The following typedefs are valid in Embedded SQL: TOCENTRY="1"LBL="Table B-1: "Valid TypedefsCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="99*"COLNAME="C2" COLWIDTH="225*"VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_BINARY   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Binary and image type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_BIT   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Bit type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_CHAR   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Character and text type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_DATETIME   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Datetime type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_FLT8   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"8-byte float type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"SQLINDICATOR   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Used for indicator variables (2-byte integer) COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_INT   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"4-byte integer COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_MONEY   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Money type COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_SMALLINT   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"2-byte integer COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_TINYINT   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"1-byte integer COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"CS_SMALLINT   COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Unsigned 2-byte integer ID="INB-3512"Implementation LimitRENDERAS="SECT2"Implementation LimitTOCENTRY="1"LBL="Table B-2: "Implementation LimitCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="45*"COLNAME="C2" COLWIDTH="295*"VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"32COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"Nesting depth for MOREINFO="NONE"exec sql include "file."NUMBER="C" ID="X48723"Embedded SQL ConstructsID="INC-3511"Statementslist ofREMAP="BO--Body"The following constructs are valid in Embedded SQL statements: TOCENTRY="1"LBL="Table C-1: "Embedded SQL ConstructsCOLS="2" CHAROFF="50" CHAR="" ALIGN="LEFT"COLNAME="C1" COLWIDTH="198*"COLNAME="C2" COLWIDTH="198*"VALIGN="TOP"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"begin MOREINFO="NONE"declare MOREINFO="NONE"sectionCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"dump MOREINFO="NONE"database COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"begin tranCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"dump MOREINFO="NONE"tran COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"begin MOREINFO="NONE"work COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"end declare section COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"checkpoint COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"exec procedure_nameCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"close cursor_name COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"execute nameCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"commit MOREINFO="NONE"tran COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"execute immediate COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"commit MOREINFO="NONE"work COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"fetch cursorCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"connect COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"grant COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"database COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"include sqlca or file COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"default COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"insert COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"table COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"open cursorCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"prepare cursor_name COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"unique MOREINFO="NONE"index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"revoke COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"clustered MOREINFO="NONE"index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"rollback MOREINFO="NONE"tran COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create nonclustered index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"rollback MOREINFO="NONE"work COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"unique MOREINFO="NONE"clustered MOREINFO="NONE"index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"select COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create unique nonclustered index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"set COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"proc COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"truncate COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"rule COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"update COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"trigger COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"use COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"create MOREINFO="NONE"view COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"whenever condition actionCOLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"declare MOREINFO="NONE"cursorCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"delete COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"disconnectCOLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"table COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"default COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"index COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"proc COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"rule COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"trigger COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"COLNAME="C1" ALIGN="LEFT" ROTATE="0" MOREROWS="0"MOREINFO="NONE"drop MOREINFO="NONE"view COLNAME="C2" ALIGN="LEFT" ROTATE="0" MOREROWS="0"ID="X62331"GlossaryarrayA structure composed of multiple identical variables which can be individually addressed.array bindingThe process of binding a result column to an array variable. At fetch time, multiple rows' worth of the column are copied into the variable.batchA group of commands or statements.A Client-Library command batch is one or more Client-Library commands terminated by an application's call to MOREINFO="NONE"ct_send. For example, an application can batch together commands to declare, set rows for, and open a cursor.A Transact-SQL statement batch is one or more Transact-SQL statements submitted to SQL Server by means of a single Client-Library command or Embedded SQL statement.browse modeBrowse mode is a method that DB-Library and Client-Library applications can use to browse through database rows, updating their values one row at a time. Cursors provide similar functionality and are generally more portable and flexible.bulk copyA utility for copying data in and out of databases. Also called MOREINFO="NONE"bcp.callback eventIn Open Client and Open Server, a callback event is an occurrence that triggers a callback routine.callback routineA routine that Open Client or Open Server calls in response to a triggering event, known as a callback event.capabilitiesA client/server connection's capabilities determine the types of client requests and server responses permitted for that connection.character setA set of specific (usually standardized) characters with an encoding scheme that uniquely defines each character. ASCII and ISO 8859-1 (Latin 1) are two common character sets.character set conversionChanging the encoding scheme of a set of characters on the way into or out of a server. Conversion is used when a server and a client communicating with it use different character sets. For example, if SQL Server uses ISO 8859-1 and a client uses Code Page 850, character set conversion must be turned on so that both server and client interpret the data passing back and forth in the same way.clientIn client/server systems, the client is the part of the system that sends requests to servers and processes the results of those requests.Client-LibraryPart of Open Client, Client-Library is a collection of routines for use in writing client applications. Client-Library is a new library, designed to accommodate cursors and other advanced features in the SYBASE 10.0 product line.code setSee character set.collating sequenceSee sort order.commandIn Client-Library, a command is a server request initiated by an application's call to MOREINFO="NONE"ct_command, MOREINFO="NONE"ct_dynamic, or MOREINFO="NONE"ct_cursor and terminated by the application's call to MOREINFO="NONE"ct_send. command structureA command structure (CS_COMMAND) is a hidden Client-Library structure that Client-Library applications use to send commands and process results. connection structureA connection structure (CS_CONNECTION) is a hidden Client-Library structure that defines a client/server connection within a context.context structureA context structure (CS_CONTEXT) is a CS-Library hidden structure that defines an application "context," or operating environment, within a Client-Library or Open Server application. The CS-Library routines MOREINFO="NONE"cs_ctx_alloc and MOREINFO="NONE"cs_ctx_drop allocate and drop a context structure.conversionSee character set conversion.CS-LibraryIncluded with both the Open Client and Open Server products, CS-Library is a collection of utility routines that are useful to both Client-Library and Server-Library applications.current rowWith respect to cursors, the current row is the row to which a cursor points. A fetch against a cursor retrieves the current row.cursorA cursor is a symbolic name that is associated with a SQL statement. In Embedded SQL, a cursor is a data selector that passes multiple rows of data to the host program, one row at a time.databaseA set of related data tables and other database objects that are organized to serve a specific purpose. datatypeA defining attribute that describes the values and operations that are legal for a variable.DB-LibraryPart of Open Client, DB-Library is a collection of routines for use in writing client applications.deadlockA situation that arises when two users, each having a lock on one piece of data, attempt to acquire a lock on the other's piece of data. SQL Server detects deadlocks and resolves them by killing one user's process. defaultDescribes the value, option, or behavior that Open Client/Server products use when none is explicitly specified.default databaseThe database that a user gets by default when he or she logs in to a database server.default language1. The language that Open Client/Server products use when an application does no explicit localization. The default language is determined by the "default" entry in the locales file. 2. The language that SQL Server uses for messages and prompts when a user has not explicitly chosen a language.Dynamic SQLDynamic SQL allows an Embedded SQL or Client-Library application to execute SQL statements containing variables whose values are determined at run-time.error messageA message that an Open Client/Server product issues when it detects an error condition.eventAn occurrence that prompts an Open Server application to take certain actions. Client commands and certain commands within Open Server application code can trigger events. When an event occurs, Open Server calls either the appropriate event-handling routine in the application code or the appropriate default event handler.event handlerIn Open Server, a routine that processes an event. An Open Server application can use the default handlers Open Server provides or can install custom event handlers. exposed structureAn exposed structure is a structure whose internals are exposed to Open Client/Server programmers. Open Client/Server programmers can declare, manipulate, and de-allocate exposed structures directly. The CS_DATAFMT structure is an example of an exposed structure.extended transactionIn Embedded SQL, an extended transaction is a transaction composed of multiple Embedded SQL statements.FIPSFIPS is an acronym for Federal Information Processing Standards. If FIPS flagging is enabled, SQL Server or the Embedded SQL precompiler issue warnings when a non-standard extension to a SQL statement is encountered.gatewayA gateway is an application that acts as an intermediary for clients and servers that cannot communicate directly. Acting as both client and server, a gateway application passes requests from a client to a server and returns results from the server to the client.hidden structureA hidden structure is a structure whose internals are hidden from Open Client/Server programmers. Open Client/Server programmers must use Open Client/Server routines to allocate, manipulate, and de-allocate hidden structures. The CS_CONTEXT structure is an example of a hidden structure.host languageThe programming language in which an application is written.host programIn Embedded SQL, the host program is the application program that contains the Embedded SQL code.host variableIn Embedded SQL, a variable which enables data transfer between SQL Server and the application program. See also indicator variable, input variable, output variable, result variable, and status variable.indicator variableA variable whose value indicates special conditions about another variable's value or about fetched data.When used with an Embedded SQL host variable, an indicator variable indicates when a database value is null.input variableA variable that is used to pass information to a routine, a stored procedure, or SQL Server.interfaces fileA file that maps server names to transport addresses. When a client application calls MOREINFO="NONE"ct_connect or MOREINFO="NONE"dbopen to connect to a server, Client-Library or DB-Library searches the interfaces file for the server's address. Note that not all platforms use the interfaces file. On these platforms, an alternate mechanism directs clients to server addresses.isql script fileIn Embedded SQL, an isql script file is one of the three files the precompiler can generate. An isql script file contains precompiler-generated stored procedures, which are written in Transact-SQL.keyA subset of row data that uniquely identifies a row. Key data uniquely describes the current row in an open cursor.keywordA word or phrase that is reserved for exclusive use in Transact-SQL or Embedded SQL. Also called a reserved word. listing fileIn Embedded SQL, a listing file is one of the three files the precompiler can generate. A listing file contains the input file's source statements and informational, warning, and error messages.locales fileA file that maps locale names to language/character set pairs. Open Client/Server products search the locales file when loading localization information.locale nameA character string that represents a language/character set pair. Locale names are listed in the locales file. SYBASE predefines some locale names, but a system administrator can define additional locale names and add them to the locales file.locale structureA locale structure (CS_LOCALE) is a CS-Library hidden structure that defines custom localization values for a Client-Library or Open Server application. An application can use a CS_LOCALE to define the language, character set, datepart ordering, and sort order it will use. The CS-Library routines MOREINFO="NONE"cs_loc_alloc and MOREINFO="NONE"cs_loc_drop allocate and drop a locale structure.localizationLocalization is the process of setting up an application to run in a particular national language environment. An application that is localized typically generates messages in a local language and character set and uses local datetime formats.login nameThe name a user uses to log in to a server. A SQL Server login name is valid if SQL Server has an entry for that user in the system table syslogins. message numberA number that uniquely identifies an error message. message queueIn Open Server, a linked list of message pointers through which threads communicate. Threads can write messages into and read messages from the queue.multi-byte character setA character set that includes characters encoded using more than one byte. EUC JIS and Shift-JIS are examples of multi-byte character sets.mutexA mutual exclusion semaphore. This is a logical object that an Open Server application uses to ensure exclusive access to a shared object.nullHaving no explicitly assigned value. NULL is not equivalent to zero, or to blank. A value of NULL is not considered to be greater than, less than, or equivalent to any other value, including another value of NULL. Open ServerA SYBASE product than provides tools and interfaces for creating custom servers.Open Server applicationA custom server constructed with Open Server.output variableIn Embedded SQL, a variable which passes data from a stored procedure to an application program.parameter1. A variable that is used to pass data to and retrieve data from a routine. 2. An argument to a stored procedure.pass-through modeA state of being pertaining to gateway applications. When in pass-through mode, a gateway relays Tabular Data Stream (TDS) packets between a client and a remote data source without unpacking the packets' contents.propertyA property is a named value stored in a structure. Context, connection, thread, and command structures have properties. A structure's properties determine how it behaves.query1. A data retrieval request; usually a MOREINFO="NONE"select statement. 2. Any SQL statement that manipulates data. registered procedureIn Open Server, a collection of C statements stored under a name. Open Server-supplied registered procedures are called system registered procedures. remote procedure call1. One of two ways in which a client application can execute a SQL Server stored procedure. (The other is with a Transact-SQL MOREINFO="NONE"execute statement.) A Client-Library application initiates a remote procedure call command by calling MOREINFO="NONE"ct_command. A DB-Library application initiates a remote procedure call command by calling MOREINFO="NONE"dbrpcinit.2. A type of request a client can make of an Open Server application. In response, Open Server either executes the corresponding registered procedure or calls the Open Server application's RPC event handler. 3. A stored procedure executed on a different server from the server to which the user is connected.result variableIn Embedded SQL, a variable which receives the results of a MOREINFO="NONE"select or MOREINFO="NONE"fetch statement.serverIn client/server systems, the server is the part of the system that processes client requests and returns results to clients.Server-LibraryA collection of routines for use in writing Open Server applications.sort orderUsed to determine the order in which character data is sorted. Also called collating sequence.sqlca1. In an Embedded SQL application, a SQLCA is a structure that provides a communication path between SQL Server and the application program. After executing each SQL statement, SQL Server stores return codes in the SQLCA.2. In a Client-Library application, a SQLCA is a structure that the application can use to retrieve Client-Library and server error and informational messages.sqlcode1. In an Embedded SQL application, a SQLCODE is a structure that provides a communication path between SQL Server and the application program. After executing each SQL statement, SQL Server stores return codes in the SQLCODE. A SQLCODE can exist independently or as a variable within a SQLCA structure.2. In a Client-Library application, a SQLCODE is a structure that the application can use to retrieve Client-Library and server error and informational message codes.SQL ServerA server in Sybase's client/server architecture. SQL Server manages multiple databases and multiple users, keeps track of the actual location of data on disks, maintains mapping of logical data description to physical data storage, and maintains data and procedure caches in memory.statementIn Transact-SQL or Embedded SQL, an instruction that begins with a keyword. The keyword names the basic operation or command to be performed. status variableIn Embedded SQL, a variable which receives the return status value of a stored procedure, thereby indicating the procedure's success of failure.stored procedureIn SQL Server, a collection of SQL statements and optional control-of-flow statements stored under a name. SQL Server-supplied stored procedures are called system procedures. System AdministratorThe user in charge of server system administration, including creating user accounts, assigning permissions, and creating new databases. On SQL Server, the System Administrator's login name is sa. system descriptorIn Embedded SQL, a system descriptor is an area of memory that holds a description of variables used in Dynamic SQL statements. system proceduresStored procedures that SQL Server supplies for use in system administration. These procedures are provided as shortcuts for retrieving information from system tables, or as mechanisms for accomplishing database administration and other tasks that involve updating system tables. system registered proceduresInternal registered procedures that Open Server supplies for registered procedure notification and status monitoring. target fileIn Embedded SQL, a target file is of the three files the precompiler can generate. A target file is similar to the original input file, except that all SQL statements are converted to Client-Library function calls.TDS(Tabular Data Stream) An application-level protocol that SYBASE clients and servers use to communicate. It describes commands and results.threadA path of execution through Open Server application and library code and the path's associated stack space, state information, and event handlers.Transact-SQLTransact-SQL is an enhanced version of the database language SQL. Applications can use Transact-SQL to communicate with SYBASE SQL Server.transactionOne or more server commands that are treated as a single unit for the purposes of backup and recovery. Commands within a transaction are committed as a group; that is, either all of them are committed or all of them are rolled back.transaction modeTransaction mode refers to the manner in which SQL Server manages transactions. SQL Server supports two transaction modes: Transact-SQL mode (also called "unchained transactions") and ANSI mode (also called "chained transactions").user nameSee login name.