[freetds] dblib and bind variables
Patrick Dunnigan
patrick.dunnigan at centivia.com
Wed Jul 20 11:54:39 EDT 2005
Hi,
Freetds .63 RC11, Fedora, MS SQL 2000.
Does dblib support the use of bind variables or placeholder syntax for sql statements?
For example, I have a sql statement that runs in a loop 100k times. The only thing that changes is a value in the where clause. If there anywhere that I can parse the SQL statement outside the loop with a placeholder and then pass in the bind variable and execute inside the loop? My thinking is that the db server would have the sql cached and wouldn't need to reparse (using Oracle as an example).
for (ii= 1; ii <= 100000; ii++) {
dbfcmd(dbproc,"select column_1, column_2 from my_table where column_3 = %d",ii);
dbsqlexec(dbproc);
dbresults(dbproc);
dbbind(dbproc, 1, INTBIND, -1, (BYTE *) &a_number);
dbbind(dbproc, 2, STRINGBIND, -1, (BYTE *) a_string);
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
printf("a_number is %d, a_string is %s\n",a_number,a_string);
}
}
Thanks
More information about the FreeTDS
mailing list