在进行Oracle SQL性能优化时,经常遇到的问题之一是SQL语句的重编译。未使用绑定变量的SQL语句如下:sprintf(sqlstr, \"insert into scott.test1 (num1, num2) values (%d,%d)\",n_var1, n_var2); EXEC SQL EXECUTE IMMEDIATE :sqlstr ; EXEC SQL COMMIT;而使用绑定变量的语句则如下:strcpy(sqlstr, \"insert into test (num1, num2) values (:v1, :v2)\"); EXEC SQL PREPARE sql_stmt FROM :sqlstr; EXEC SQL EXECUTE sql_stmt USING :n_var1, :n_var2; EXEC SQL COMMIT;