#docslug#/ecob/ecob/V1.1.6/precompiled-statements OceanBase Embedded SQL in C (ECOB) supports the following statements related to the prepared (precompiled) statements: PREPARE and EXECUTE. They are dynamic SQL statements and can include a fixed number of input or output host variables.
PREPARE
You can execute the PREPARE statement to prepare (precompile) an SQL statement in PS mode.
Syntax:
EXEC SQL PREPARE (statement_id) FROM (:host_string | 'sql text' | select_command)

Sample statement:
char * sql = "insert into proctest(c1,c2,c3) values (:c1,:c2,:c3)";
EXEC SQL PREPARE stat FROM :sql;
EXECUTE
You can execute the EXECUTE statement to execute a prepared SQL statement.
Syntax:
EXEC SQL EXECUTE (statement_id) [USING :host_variable [ [INDICATOR] :indicator_variable]
EXEC SQL EXECUTE (statement_id) [INTO :host_variable]
EXEC SQL EXECUTE (statement_id) [USING SQL DESCRIPTOR descriptor]



Sample statement:
int c1val = 10;
int c2val = 20;
char c3val[100];
int c4val = 0;
char * sql = "insert into t1(c1,c2,c3) values (:c1,:c2,:c3)";
memset(c3val,0,sizeof(c3val));
EXEC SQL CRETAE TABLE t1 (c1 int,c2 int ,c3 varchar2(100));
EXEC SQL PREPARE stat FROM :sql;
strcpy(c3val,"this is a demo");
EXEC SQL EXECUTE stat USING :c1val,:c2val,:c3val;
EXEC SQL PREPARE q FROM 'delete from t1';
EXEC SQL EXECUTE q;
EXEC SQL PREPARE ps FROM 'select 1 from dual';
EXEC SQL EXECUTE ps INTO :c4val;
EXEC SQL ALLOCATE DESCRIPTOR in_desc;
EXEC SQL EXECUTE ps USING SQL SQL_DESCRIPTOR in_desc;
EXEC SQL DROP TABLE t1;
EXEC SQL DEALLOCATE DESCRIPTOR in_desc;