Using EXECUTE IMMEDIATE

From InterBase
Jump to: navigation, search

Go Up to Method 1: Non-query Statements Without Parameters (Embedded SQL Guide)


  1. To execute a statement string a single time, use EXECUTE IMMEDIATE:
  2. Elicit a statement string from the user or create one that contains the SQL statement to be processed. For example, the following statement creates a SQL statement string:
char *str = "UPDATE DEPARTMENT SET BUDGET = BUDGET * 1.05";
3. Parse and execute the statement string using EXECUTE IMMEDIATE:
EXEC SQL
EXECUTE IMMEDIATE :str;
Note: EXECUTE IMMEDIATE also accepts string literals. For example,
EXEC SQL
EXECUTE IMMEDIATE
'UPDATE DEPARTMENT SET BUDGET = BUDGET * 1.05';