Embedded Applications

From InterBase
Jump to: navigation, search

Go Up to Application Development


You can write your application using C or C++, or another programming language, and embed SQL statements in the code. You then preprocess the application using gpre, the InterBase application development preprocessor. gpre takes SQL embedded in a host language such as C or C++ and generates a file that a host-language compiler can compile.

The gpre preprocessor matches high-level SQL statements to the equivalent code that calls functions in InterBase client API library. Therefore, using embedded SQL affords the advantages of using a high-level language, and the runtime performance and features of the InterBase client API.

For more information about compiling embedded SQL applications, see the Embedded SQL Guide.

Predefined Database Queries

Some applications are designed with a specific set of requests or tasks in mind. These applications can specify exact SQL statements in the code for preprocessing. gpre translates statements at compile time into an internal representation. These statements have a slight speed advantage over dynamic SQL because they do not need to incur the overhead of parsing and interpreting the SQL syntax at runtime.

Dynamic Applications

Some applications must handle ad hoc SQL statements entered by users at run time; for example, allowing a user to select a record by specifying criteria to a query. This requires that the program constructs the query based on user input.

InterBase uses Dynamic SQL (DSQL) for generating dynamic queries. At run time, your application passes DSQL statements to the InterBase server in the form of a character string. The server parses the statement and executes it.

BDE provides methods for applications to send DSQL statements to the server and retrieve results. ODBC applications rely on DSQL statements almost exclusively, even if the application interface provides a way to visually build these statements. For example, Query By Example (QBE) or Microsoft Query provide convenient dialogs for selecting, restricting and sorting data drawn from a BDE or ODBC data source, respectively.

You can also build templates in advance for queries, omitting certain elements such as values for searching criteria. At run time, supply the missing entries in the form of parameters and a buffer for passing data back and forth.

For more information about DSQL, see the Embedded SQL Guide.