Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> metalink article "tuning precompiler applications" and bind vars
<pro*c question>
in metalink document id note:73922.1 (tuning precompiler applications) section a. (bind variables), it provides the following two snippets. it further states that the first example requires 100 parses but the second only 1. is this because the string from which the statement is prepared is dynamic? what if instead, the statement inside of the loop was:
exec sql update emp set
sal=sal*1.1
where emp_no = :empno_bind_var;
would this statement need be parsed multiple times? the statement hasn't changed, just the contents of the host variable.
many thanks.
int empno_bind_var;
char dyn_stmt[255];
...
for (empno_bind_var = 1; empno_bind_var<=100; empno_bind_var++)
{
sprintf(dyn_stmt, "update emp set sal=sal*1.1 where empno= %d",
empno_bind_var);
EXEC SQL EXECUTE IMMEDIATE :stmt;
}
int empno_bind_var;
char dyn_stmt[255];
...
sprintf(dyn_stmt, "update emp set sal=sal*1.1 where empno= :b1");
EXEC SQL PREPARE sql_stmt FROM :dyn_stmt;
for (empno_bind_var = 1; empno_bind_var<=100; empno_bind_var++)
{
EXEC SQL EXECUTE sql_stmt USING :emp_bind_var;
}
-- Microsoft gives you Windows but Unix gives you the whole house!Received on Thu Jan 04 2001 - 16:24:05 CST