Executes a SQL statement.
Executes a SQL statement and returns the number of affected rows for
INSERT, UPDATE, and DELETE. For other operations, function returns 0.
If an error occurs in the SQL statement and exec_sql() is part of an
expression, the function returns -1.
If exec_sql() is not part of an expression and error occurs, the
function escapes to the
window trigger error trap or, for reports and stand-alone TRIMpl,
operating system command shell.
The host variable reference character varies between databases. To
maintain database portability, use the Oracle ``:n'' notation; on all other
systems, the ``:n'' is automatically replaced by ``?'' notation.
host-variable|| (optional) specifies the bind variables (either as
variables or hard-coded) for the statement. If
host-variable is a list, all host-variable references are
resolved from the list.
Sybase stored procedures can be executed by using exec_sql(), which
returns either the number of rows processed or the raiserror
value in case of error. The raiserror or print message can be retrieved
count = exec_sql("insert_proc",id,name);
Increases the salary of everyone in department 58;
a prompt asks for the percent increase for each person.
if (DEPT == 58)
exec_sql("UPDATE staff SET sal = sal * " ^^
1 + prompt("Enter increase for " ^^ NAME ^^ " ==> ") / 100 ^^
" where NAME = " ^^ NAME);
Delete all employees whose salary is greater than max_salary.
if (exec_sql("DELETE FROM staff WHERE sal > :1",max_salary) < 0)
printf("Error occurred while deleting overpaid employees");