Updated on 2024-05-07 GMT+08:00

Executing a Statement Without a Result Set

An example of running the EXECUTE IMMEDIATE command is as follows:
EXEC SQL BEGIN DECLARE SECTION;
    const char *stmt = "CREATE TABLE test1 (...);";
EXEC SQL END DECLARE SECTION;
    EXEC SQL EXECUTE IMMEDIATE :stmt;

EXECUTE IMMEDIATE can be used for SQL statements that do not return a result set, such as DDL, INSERT, UPDATE, and DELETE statements. However, statements for retrieving data, such as SELECT statements, cannot be executed in this way.