EXECUTE IMMEDIATE

Embedded SQL for C and SQL Server

Embedded SQL for C and SQL Server

EXECUTE IMMEDIATE

The EXECUTE IMMEDIATE statement runs the embedded SQL statement contained in the specified host variable.

Syntax

EXECUTE IMMEDIATE :stmt_hvar

Arguments

stmt_hvar

Is a character string host variable that contains a Transact-SQL statement.

Remarks

The EXECUTE IMMEDIATE statement must conform to Transact-SQL statement rules. It cannot contain input parameter markers or host variables. It cannot return results. Results returned from this statement are discarded. Additionally, the statement cannot contain keywords that pertain exclusively to ESQL/C.

If any rows are returned, SQLCODE is set to +1, which indicates an exception.

Examples
strcpy(prep, "DELETE FROM mf_table WHERE name='elaine'");

EXEC SQL EXECUTE IMMEDIATE :prep;

See Also

EXECUTE