As explained in the eXtremeSQL C API page, an embedded SQL application will define its database schema using the eXtremeDB DDL then compile the schema using
mcocomp
as for all C and C++ applications. The applications will then use the static C API functions to start the eXtremeSQL runtime, specify memory devices and database parameters, and then callmco_db_open_dev()
to open the database andmco_db_connect()
to create a database connection. This database connection (handle) is then passed to the eXtremeSQL functionmco_api_initialize()
to initialize the SQL wrapper. Thenmcosql_open()
is called to open an SQL engine.This SQL engine structure is used for all SQL database access through functions
mcosql_execute_query()
andmcosql_execute_statement()
.Processing SQL Queries
The C structures
data_source_t, cursor_t
andrecord_t
are provided for processing query results. Typically the address of adata_source_
t will be passed with aselect
statement to functionmcosql_execute_query()
to obtain a result set; then acursor_t
will be created by functionmcosql_get_cursor()
which is used to iterate the result set (data source) . Cursor navigation functionsmcosql_move_first(), mcosql_move_next(), mcosql_move_last()
andmcosql_move_prev()
are used to position the cursor and obtain arecord_t
handle for the current result set row. The individual column values of the result set row (record) can then be accessed with functionmcosql_get_column_value()
. When finished, the functionmcosql_release_query_result()
must be called to release the dynamic memory resources allocated for thisdata_source_t
.Executing SQL Statements
The SQL engine structure is passed to function
mcosql_execute_statement()
with aninsert, update
ordelete
statement to modify database contents. A number of argument substitution specifiers are provided for constructing SQL statements.Prepared Statements
SQL statements can be prepared and reused multiple times. This saves processor time by eliminating the statement compilation step each time the statement is executed. An even more significant advantage is that the prepare step binds its statement arguments only once and then reuses these arguments in further calculations. This can have a noticeable effect because, unlike the
mcosql_execute_query()
andmcosql_execute_statement()
functions,mcosql_prepare_statement()
works only with pointers to arguments. Thus the values of arguments are bound at the prepare step so that themcosql_execute_prepared_query()
ormcosql_execute_prepared_statement()
functions work with the actual values of these statement arguments.eXtremeSQL Application Implementation Details
Please use the links below to view details of the category of APIs of interest:
Runtime Initialization eXtremeSQL runtime initialization Engine Initialization SQL engine initialization Queries Executing database queries Statements Executing other SQL statements Prepared Statements Executing Prepared Statements Argument Substitution SQL Statement Argument Substitution Transactions Managing database transactions Metadata Saving database metadata Mixing Languages Mixing the C language API with C++