|
 
Introduction
Using
SQL Within an Application
Introduction
SQL
is a dual-mode language. It is both an interactive database languages
used for communicating with database (commonly refer as Interactive
SQL), via interactive tool to access database, and a programmatic database
language used by application programs for database access.
For First
mode, usually every major DBMS product will provide their own user interface
for using SQL, for example: DBMaker provides dmsqlc, user can input
SQL syntax directly through the tool to access and maintain their database.
For second
mode, most major DBMS also provide two basic techniques for user to
use SQL in their program. They are Database API and Embedded SQL.
Using
SQL Within an Application
Using SQL
exclusively for such programs is possible through the use of an application
program interface (API). This is a set of function calls that submits
the SQL statements to the DBMS and retrieves query results. For this,
DBMaker provides the industry standard database APIODBC (Open Database
Connectivity).
Embedded
SQL (ESQL) is another approach. SQL statements, with some minor changes
to form, can be written directly into the source code of an application
program among the statements of the host programming language. This
mixed source code is then processed by an SQL precompiler, which stores
the SQL commands in the database and generates host language function
calls to execute the stored commands. This manual describes the specification
and design of DBMaker ESQL.
You can
write C application programs that use ESQL commands to access a DBMS.
The DBMaker C preprocessor prepares the application program containing
the SQL commands for the C compiler. The preprocessor converts the SQL
commands to C statements (with C comments) to perform the database operations.
The procedures
for creating and running an ESQL C application program are:
- Design
and write the program with embedded SQL.
- Preprocess
the program using the DBMaker C preprocessor dmppcc.
- Compile
and link the program generated by the preprocessor.
- Execute
the program.
The figure
on the following page shows the process for creating an ESQL C application.
Appendix
A has a sample program showing both before and after preprocessing.
You may find it useful to review the program first.

  
|