Parameters
statement | SQL language command |
Since version:
5.0, modified in 8.0
Description
This function executes the SQL language command specified in the statement parameter. The command's validity is not checked when compiling this function syntax - if there's a syntax error in the SQL command, it will take effect during runtime, when the SQL server displays a message that the request cannot be done. You may specify more SQL command in the statement parameter. The commands must be separated with semicolons.
If you specify more commands separated with semicolons, they will be executed in a single transaction.
Function value
This function returns either the compiling error number, if the specified command cannot be compiled, or 0, if the command's execution was successful - see Dynamic SQL commands inside stored procedures.
Example:
if a compiling error may occur, you must treat it in the code (cannot be caught using a handler):
SET tabname="nonex_tab" ;
SET auxstr="INSERT INTO "||tabname||" DEFAULT VALUES";
SET err=SQL_execute(auxstr);
IF err=1069 THEN
CALL Log_write("compiler error: table >"|| tabname||"< doesn't exist!!");
ELSEIF err>0 THEN
CALL Log_write("compiler error:"||Int2str(err));
ELSE ...
See