Embedded SQL Companion Guide
1. Introducing the Embedded SQL Companion Guide
In This Guide
Audience
Contents
Enterprise Access Compatibility
Conventions
Statements and Commands
Terminology
Syntax
System-Specific Text
Related Manuals
2. Embedded SQL for C
Embedded SQL Statement Syntax for C
Margin
Terminator
Labels
Line Continuation
Comments
String Literals
String Literals and Statement Strings
The Create Procedure Statement
Sub-Processes in ESQL/C Programs
C Variables and Data Types
Variable and Type Declarations
Embedded SQL Variable Declaration Sections
Reserved Words in Declarations
Data Types
# Define Declaration
Variable Declarations Syntax
Type Declarations Syntax
Array Declarations Syntax
Pointer Declarations Syntax
Structure Declarations Syntax
Enumerated Integer Types
Varying Length String Type
Varying Length Binary Type
DCLGEN Utility
language
dbname
tablename
filename
structurename
Indicator Variables
How to Declare External Compiled Forms
Embedded SQL/C Declarations Example
The Scope of Variables
Variable Usage
Simple Variables
Array Variables
Pointer Variables
Structure Variables
Indicator Variables Usage
Varchar Variables for Logical Key Data Types
How Function Arguments are Declared
Data Type Conversion
Runtime Numeric Type Conversion
Runtime Character Type Conversion
How Varchar is Used to Receive and Set Character Data
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
condition
action
Whenever Goto Action In Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for C
SQLDA Structure Usage
How to Declare an SQLDA Variable
Dynamic Allocation of an SQLDA
Static Declaration of an SQLDA
The SQLVAR Array
C Variable Type Codes
Character Data and the SQLDA
Binary Data and the SQLDA
Pointer Usage with C Variables
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
User-Defined Data Handlers for Large Objects
ESQL/C Usage Notes
Data Handlers and the SQLDA
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Include File Processing
Source Code with Labels
Coding Requirements for Embedded SQL Programs
Comments Embedded in C Output
How Statements are Embedded Inside C If Blocks
Embedded SQL Statements that Do Not Generate Code
Command Line Operations
esqlc Command – Invoke Embedded SQL Preprocessor for C
The C Compiler
How Embedded SQL Programs are Linked—Windows
Programs Without Embedded Forms
Link Precompiled Forms
How Embedded SQL Programs are Linked—UNIX
Programs Without Embedded Forms
Link Precompiled Forms
How Embedded SQL Programs are Linked—VMS
Link Precompiled Forms
How Embedded SQL Programs are Linked Without Shared Libraries
User-Written Embedded SQL Routines in Shareable Images
Embedded SQL/C Preprocessor Errors
C++ Programming
How to Create ESQL/C++ Programs
Program Comments
How Data is Declared
How to Transfer Data Between Programs and the Database
How to Declare Function Parameters
DCLGEN and ESQL/C++
Ingres Runtime Library Prototypes
4GL Restriction
How to Create User-Defined Handlers
How to Build ESQL/C++ Programs
Sample ESQL/C++ Application
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor-Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
Multi-Threaded Applications
Current Session
SQLCA Diagnostic Area
3. Embedded SQL for COBOL
Embedded SQL Statement Syntax for COBOL
Margin
COBOL Sequence Numbers
Terminator
Labels
Line Continuation
Comments
String Literals
String Literals and Statement Strings
The Create Procedure Statement
COBOL Data Items and Data Types
Variable and Type Declarations
Embedded SQL Variable Declaration Sections
Data Item Declaration Syntax
Reserved Words in Declarations
Data Types
Alphabetic, Alphanumeric, and Alphanumeric Edited Categories
Indicator Data Items
Numeric Edited Data Category
Numeric Data Category—Windows and UNIX
Numeric Data Category—VMS
Record Declarations
DCLGEN Utility
language
dbname
tablename
filename
structurename
How to Declare External Compiled Forms—Windows and UNIX
How to Assemble and Declare External Compiled Forms—VMS
Embedded SQL/COBOL Declarations Example
The Scope of Variables
Variable Usage
Elementary Data Items
COBOL Tables
Record Data Items
Elementary Items from a Record
Indicator Data Items
Data Type Conversion
Decimal Type Conversion
Runtime Numeric Type Conversion
Runtime Character and Varchar Type Conversion
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
condition
action
Whenever Goto Action in Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for COBOL
SQLDA Record Usage
How to Declare an SQLDA Record
The SQLVAR Table
COBOL Data Item Type Codes
Pointer Usage with COBOL Data Items
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
Include User-Defined Handlers in the Micro Focus RTS—UNIX
User-Defined Data Handlers for Large Objects
ESQL/COBOL Usage Notes
Data Handlers and the SQLDA
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Include File Processing
Include Files—Windows and UNIX
filename
Include Files—VMS
filename
Source Code with Labels
Coding Requirements for Embedded SQL Programs
Comments Embedded in COBOL Output
Embedded SQL Statements in IF and PERFORM Blocks
COBOL Periods and Embedded SQL Statements
Embedded SQL Statements That Do Not Generate Code
Efficient Code Generation
Command Line Operations
esqlcbl Command – Invoke Embedded SQL Preprocessor for COBOL
Source Code Format
Format Considerations—Windows and UNIX
Format Considerations—VMS
The COBOL Compiler—Windows and UNIX
The COBOL Compiler—Windows Micro Focus Net Express
The COBOL Compiler—VMS
How Embedded SQL Programs are Linked
How Embedded SQL Programs are Linked without Shared Libraries
How to Place User-Written Embedded SQL Routines in Shareable Images
How to Incorporate Ingres into the Micro Focus RTS—UNIX
How to Build an Ingres RTS without the Ingres FRS
How to Build an RTS with the Ingres FRS
How to Include External Compiled Forms in the RTS
Embedded SQL/COBOL Preprocessor Errors
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor–Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
4. Embedded SQL for Fortran
Embedded SQL Statement Syntax for Fortran
Margin
Terminator
Labels
Line Continuation
Comments
String Literals
String Literals and Statement Strings
The Create Procedure Statement
Fortran Variables and Data Types
Variable and Type Declarations
Embedded SQL Variable Declaration Sections
Reserved Words in Declarations
Variable and Type Declarations
Constant Declarations
Data Types
Structure and Record Declarations Syntax
DCLGEN Utility
language
dbname
tablename
filename
structurename
Indicator Variables
How to Declare External Compiled Forms
Embedded SQL/Fortran Declarations Example
The Scope of Variables
Variable Usage
Simple Variables
Array Variables
Structure Variables
Indicator Variables Usage
Data Type Conversion
Ingres and Fortran Data Type Compatibility
Runtime Numeric Type Conversion
Runtime Character and Varchar Type Conversion
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
Whenever Goto Action in Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for Fortran
SQLDA Structure Usage
How to Declare an SQLDA Variable
SQLVAR Array Usage
Fortran Variable Type Codes
Pointer Usage with Fortran Variables
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
User-Defined Data Handlers for Large Objects
ESQL/Fortran Usage Notes
DATAHANDLERS and the SQLDA
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Include File Processing
Include Files – UNIX
filename
Include Files – VMS
filename
Include Files – Windows
filename
Source Code with Labels
Coding Requirements for Embedded SQL Programs
Comments Embedded in Fortran Output
Embedded SQL Statements and Fortran If Blocks
Embedded SQL Statements that Generate Labels
Embedded SQL Statements that Do Not Generate Code
Command Line Operations
esqlf Command – Invoke Embedded SQL Preprocessor for Fortran
The Fortran Compiler
How Embedded SQL Programs are Linked
Link Precompiled Forms
How Embedded SQL Programs are Linked without Shared Libraries -VMS
How to Place User-written Embedded SQL Routines in Shareable Images -VMS
Embedded SQL/Fortran Preprocessor Errors
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor-Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
Sample Application Compiled with /float=ieee Flag (VMS)
5. Embedded SQL for Ada
Embedded SQL Statement Syntax for Ada
Margin
Terminator
Labels
Line Continuation
Comments
String Literals
String Literals and Statement Strings
The Create Procedure Statement
Ada Variables and Data Types
Embedded SQL/Ada Declarations
Embedded SQL Variable Declaration Sections
Reserved Words in Declarations
Data Types
Constants
Integer Data Types
Float Data Types
Long Float Storage Format
Character and String Data Types
Variable and Number Declaration Syntax
Simple Variable Declarations
Type Constraints
Formal Parameter Declarations
Number Declarations
Rename Variables
Type Declaration Syntax
DCLGEN Utility
language
dbname
tablename
filename
recordname
Indicator Variables
How to Declare External Compiled Forms
Embedded SQL/Ada Declarations Example
The Scope of Variables
Variable Usage
Simple Variables
Array Variables
Record Variables
Access Variables
Indicator Variables
Data Type Conversion
Ingres Data Types and Corresponding Ada Data Types
Runtime Numeric Type Conversion
Runtime Character and Varchar Type Conversion
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
condition
action
The Whenever Goto Action in Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for Ada
The SQLDA Record
How to Declare an SQLDA Record Variable
SQLVAR Array Usage
Ada Variable Type Codes
SQL Type Codes
Pointer Usage with Ada Variables
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
User-Defined Data Handlers for Large Objects
ESQL/Ada Usage Notes
DATAHANDLERS and the SQLDA
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Include File Processing
How to Include Variable Declarations
How to Include Package Specifications
Coding Requirements for Embedded SQL Programs
Comments Embedded in Ada Output
Embedded SQL Statements that Do Not Generate Code
Command Line Operations
esqla Command – Invoke Embedded SQL Preprocessor for Ada
The ACS Environment and the Ada Compiler
How to Enter Embedded SQL Package Specifications
How to Define Long Floating-point Storage
The Ada Compiler
How Embedded SQL Programs are Linked
Link Precompiled Forms
How to Link Embedded SQL Programs without Shared Libraries
Embedded SQL/Ada Preprocessor Errors
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor-Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
6. Embedded SQL for BASIC
Embedded SQL Statement Syntax for BASIC
Margin
BASIC Line Numbers
Terminator
Labels
Line Continuation
Comments
String Literals
Integer Literals
The Create Procedure Statement
Decimal Literals
BASIC Variables and Data Types
Variable Declarations
Embedded SQL Variable Declaration Sections
Reserved Words in Declarations
Data Types
Variable and Constant Declaration Syntax
DCLGEN Utility
language
dbname
tablename
filename
recordname
How to Declare External Compiled Forms
Embedded SQL/BASIC Declarations Example
The Scope of Variables
Variable Usage
Simple Variables
Array Variables
Record Variables
Indicator Variables
Data Type Conversion
Ingres and BASIC Data Type Compatibility
Runtime Numeric Type Conversion
Runtime Character and Varchar Type Conversion
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
condition
action
The Whenever Goto Action in Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for BASIC
The SQLDA Record
How to Declare an SQLDA Variable
SQLVAR Usage
BASIC Variable Type Codes
SQLDA Type Codes
Pointer Usage with BASIC Variables
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
User-Defined Data Handlers for Large Objects
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Command Line Operations
esqlb Command — Invoke Embedded SQL Preprocessor for BASIC
esqlb Command Options
The BASIC Compiler
How Embedded SQL Programs are Linked
Link Precompiled Forms
How Embedded SQL Programs are Linked without Shared Libraries
User-written Embedded SQL Routines in Shareable Images
Include File Processing
Source Code with Labels
Coding Requirements for Embedded SQL Programs
Comments Embedded in BASIC Output
Embedded Statements Inside BASIC If Blocks
Embedded SQL Statements that Do Not Generate Code
Embedded SQL/BASIC Preprocessor Errors
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor-Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
7. Embedded SQL for Pascal
Embedded SQL Statement Syntax for Pascal
Margin
Terminator
Labels
Line Continuation
Comments
String Literals
String Literals and Statement Strings
The Create Procedure Statement
Decimal Literals
Pascal Variables and Data Types
Embedded SQL/Pascal Declarations
Embedded SQL Variable Declaration Sections
Reserved Words in Declarations
Data Types
Constants
Integer Data Types
Indicator Data Types
Floating-Point Data Types
Double Storage Format
Character Data Types
Declaration Syntax
Enumeration Type Definitions
Subrange Type Definitions
Pointer Type Definitions
Varying Length String Type Definition
Record Type Definitions
Set Type Definitions
The DCLGEN Utility
language
dbname
tablename
filename
recordname
Pre-declared Identifiers
Program Syntax
Procedures
Functions
How to Declare External Compiled Forms
Embedded SQL/Pascal Declarations Example
The Scope of Variables
Variable Usage
Simple Variables
Array Variables
Record Variables
Pointer Variables
Indicator Variables
Data Type Conversion
Ingres and Pascal Data Type Compatibility
Runtime Numeric Type Conversion
Runtime Character and Varchar Type Conversion
The SQL Communications Area
The Include SQLCA Statement
Contents of the SQLCA
Error Handling Using the SQLCA
Error Handling with the Whenever Statement
condition
Whenever Goto Action in Embedded SQL Blocks
Explicit Error Handling
How to Determine the Number of Affected Rows
SQLSTATE Variable Usage
Dynamic Programming for Pascal
SQLDA Record Usage
How to Declare an SQLDA Record Variable
SQLVAR Array Usage
Pascal Variable Type Codes
Pointer Usage with Pascal Variables
How to Set SQLNAME for Dynamic FRS
Advanced Processing
User-Defined Error, DBevent, and Message Handlers
How to Declare User-Defined Handlers
User-Defined Data Handlers for Large Objects
Sample Programs
Handler
Put Handler
Get Handler
Dynamic SQL Handler
Preprocessor Operation
Command Line Operations
esqlp – Invoke Embedded SQL Preprocessor for Pascal
esqlp Command Options
The Pascal Compiler
How Embedded SQL Programs are Linked
Link Precompiled Forms
How to Link Embedded SQL Programs without Shared Libraries
User-written Embedded SQL Routines in Shareable Images
Include File Processing
Source Code with Labels
Coding Requirements for Embedded SQL Programs
Comments Embedded in Pascal Output
Embedded Statements Inside Pascal If Blocks
Embedded SQL Statements That Do Not Generate Code
Embedded SQL/Pascal Preprocessor Errors
Preprocessor Error Messages
Sample Applications
The Department-Employee Master/Detail Application
The Table Editor Table Field Application
The Professor-Student Mixed Form Application
The SQL Terminal Monitor Application
A Dynamic SQL/Forms Database Browser
Ingres 10S
A Dynamic SQL/Forms Database Browser