Skip to Content.
Sympa Menu

freetds - [freetds] Problem with stored proc and varchar parameters

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: bflood AT tethermedia.com
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Problem with stored proc and varchar parameters
  • Date: Thu, 13 Jul 2006 13:18:45 -0400 (EDT)

Hi,

I am new to freetds. I just downloaded stable version (0.64) yesterday and
have a simple ODBC app that I am trying to get working on linux
(connecting to SQL Server on a windows box). I have a stored proc that
takes a varchar (basically a string of up to 10 chars). However when I
execute it no character data gets sent across the wire. If I change the
proc to take an INTEGER then it works (and I see the parm value in the TDS
stream).

Below is the statement and dump from tds log. You can see for some reason
the colsize is 0 when I sned a varchar string, but 4 when I send an
integer. Here is the ODBC code and tds log snapshot for each case. If I am
doing something wrong or this is a known problem let me know, otherwise I
will look into the odbc / tds code to figure out what might be going
wrong.

This is the failing code (with the varchar param)

ret = SQLBindParameter( m_hStmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_VARCHAR, 0, 0, (void*)"8005551212", 10, NULL );
ret = SQLExecDirect(m_hStmt, (SQLCHAR*)"{CALL get_some_data(?)}",
SQL_NTS);

12:58:15.986075 6166 (query.c:1238):tds_put_data_info putting param_name
12:58:15.986095 6166 (query.c:1267):tds_put_data_info putting status
12:58:15.986111 6166 (query.c:1362):tds_put_data: colsize = 0
12:58:15.986127 6166 (query.c:1391):tds_put_data: not null param
varint_size = 2
12:58:15.986147 6166 (util.c:119):Changing query state from QUERYING to
PENDING
12:58:15.986164 6166 (net.c:673):Sending packet
0000 03 01 00 32 00 00 01 00-0d 00 67 00 65 00 74 00 |...2.... ..g.e.t.|
0010 5f 00 73 00 6f 00 6d 00-65 00 5f 00 64 00 61 00 |_.s.o.m. e._.d.a.|
0020 74 00 61 00 00 00 00 00-a7 00 00 09 04 d0 00 34 |t.a..... .......4|
0030 00 00 - |..|

This is the passing code with INTEGER parameter

int id = 3;
ret = SQLBindParameter( m_hStmt, 1, SQL_PARAM_INPUT, SQL_C_LONG,
SQL_INTEGER, 0, 0, &id, 4, NULL );
ret = SQLExecDirect(m_hStmt, (SQLCHAR*)"{CALL get_some_data(?)}",
SQL_NTS);
13:01:30.523950 6178 (query.c:1238):tds_put_data_info putting param_name
13:01:30.523968 6178 (query.c:1267):tds_put_data_info putting status
13:01:30.523985 6178 (query.c:1362):tds_put_data: colsize = 4
13:01:30.524001 6178 (query.c:1391):tds_put_data: not null param
varint_size = 1
13:01:30.524018 6178 (util.c:119):Changing query state from QUERYING to
PENDING
13:01:30.524036 6178 (net.c:673):Sending packet
0000 03 01 00 2f 00 00 01 00-0d 00 67 00 65 00 74 00 |.../.... ..g.e.t.|
0010 5f 00 73 00 6f 00 6d 00-65 00 5f 00 64 00 61 00 |_.s.o.m. e._.d.a.|
0020 74 00 61 00 00 00 00 00-26 04 04 03 00 00 00 |t.a..... &......|

Thanks in advance for any help or pointers.

Brendan Flood
Tethermedia LLC
http://www.tethermedia.com






Archive powered by MHonArc 2.6.24.

Top of Page