Selectively Bypassing the Creation of Access Plans

Embedded SQL for C and SQL Server

Embedded SQL for C and SQL Server

Selectively Bypassing the Creation of Access Plans

To run a stored procedure by using a static SQL statement, include an EXEC statement before the stored procedure call to bypass the creation of an access plan. If you do not include an EXECUTE statement before the stored procedure call, a stored procedure is created to run the stored procedure that was called. Using EXECUTE eliminates this extra step; for example:

EXEC SQL EXEC sp-addlogin :loginame, :password;

You can also use the selective bypass method to issue an SQL statement dynamically from a static SQL statement without using the PREPARE and EXECUTE statements, for example:

EXEC SQL EXEC CREATE TABLE t1 (c1 int, ...);

The current values of any host variables are substituted into the statement.