Skip to Content.
Sympa Menu

freetds - [ODBC] SQLBindParameter

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Ken Seymour <kenaseymour AT yahoo.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: [ODBC] SQLBindParameter
  • Date: Mon, 28 Feb 2000 10:03:52 -0800 (PST)


Brian,

This weekend, I decided to test the ODBC driver with
parameterized select statements.

To do this I used the pubs2 example database and did
the following:

select title from titles
where total_sales = ?

This requires calling, in order:

SQLPrepare
SQLBindParameter
SQLExecute

I debugged into SQLBindParameter and found that the
param_info structure was not allocated. So I added
a call to tds_alloc_param_result (in tds/mem.c).
This caused a SEGV and upon further inspection,
this routine looks like it is missing a malloc.

It was after I added this and got SQLBindParameter
working that I discovered that SQLExecute does not
make use of the parameters and Sybase attempts to
give me a message of 'syntax error near ?' or
something like that.

To my knowledge, there are not parameter routines in
tds (or dblib for that matter). So I suppose I will
have to implement it on the client side.
Since I suspect that SQLPrepare can be called once
and SQLExecute several times with different parameter
values (in the same bound variables), I will need
to keep the original SQL text, substitute the question
marks for the stored parameter values, and pass along
the translated SQL text to TDS.

I am getting ready to check in changes to odbc/odbc.c
and tds/mem.c. I wanted to check in with you first
since this is outside the odbc tree.

I will add

param_info->columns[0] = (TDSCOLINFO*)
malloc (sizeof (TDSCOLINFO));

before the second memset in if (!oldparam) and add


param_info->columns[param_info->num_cols-1] =
(TDSCOLINFO*) malloc (sizeof (TDSCOLINFO));

before the second memset in the else block.

What do you think?

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




Archive powered by MHonArc 2.6.24.

Top of Page