Skip to Content.
Sympa Menu

freetds - [freetds] dblib and bind variables

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Patrick Dunnigan" <patrick.dunnigan AT centivia.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] dblib and bind variables
  • Date: Wed, 20 Jul 2005 11:54:39 -0400

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




Archive powered by MHonArc 2.6.24.

Top of Page