OceanBase Embedded SQL in C (ECOB) is an OceanBase precompiler that provides features that are compatible with Oracle Pro*C.
Pro*C is a tool provided by the Oracle Database ecosystem to develop applications. When you develop an application in the C language, you can directly embed SQL statements into the source code of the application. These embedded SQL statements can take C language variables in the host C application as the input and output. Then, proc, the precompiling program of Pro*C, preprocesses the source code for complete semantic analysis and converts the embedded SQL statements and commands to calls of functions in the sqllib runtime library. Finally, a source code file of the application in C is generated. This file is compiled and linked by the C language compiler and generated as an executable program. To provide support for Pro*C, OceanBase develops ECOB that contains the ecob precompiler and the ecoblib runtime library.
A PROC program comprises a great number of PC files and is built by using methods such as makefiles. To minimize your migration costs, the ecob precompiler provides command-line tool options and features that are the same as those of the PROC program.
Features
ECOB of the current version provides the following features:
Supports SQL syntax that is compatible with the OceanBase Oracle mode.
Supports basic embedded SQL statements, such as
COMMIT,CONNECT,DELETE,EXECUTE,EXECUTE IMMEDIATE,INSERT,SELECT,UPDATE,WHENEVER,CALL,PREPARE, andROLLBACK.Supports cursor-related statements, such as
DECLARE,OPEN,CLOSE, andFETCH(includingNEXT,ABSOLUTE,WITH HOLD, andCURRENT OF).Supports
descriptorsrequired by ANSI dynamic SQL and descriptor-related statements, such asALLOCATE,DEALLOCATE,GET,SET,DESCRIBE, andFETCH.Supports the direct use of host variables without declaration in
BEGIN DECLARE SECTIONandEND DECLARE SECTION.Recognizes and processes C preprocessor macros #ifdef, #ifndef, #else, #endif, and #define.
The ecoblib library supports the runtime behavior of all the preceding statements. The ecoblib library provides options (such as CHAR_MAP) that are compatible with the proc program and allows the program to run in the Tuxedo environment.
An ecob program recognizes all options and compatible semantics of PROC programs and can be used as a replacement for PROC programs.
Architecture
ECOB comprises the ecob precompiler and the ecoblib library (libecob.so), a runtime dynamic link library. The architecture is shown in the following figure.