-
绑定变量有助于解决重编译问题,以实现ORACLE+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;