[freetds] TDS_DONE_TOKEN (and others)

Frediano Ziglio freddyz77 at tin.it
Thu May 1 12:46:09 EDT 2003

Il gio, 2003-05-01 alle 16:08, Lowden, James K ha scritto:
> > From: Frediano Ziglio [mailto:freddyz77 at tin.it]
> > Sent: May 1, 2003 3:30 AM
> > 
> > you can use syntax like enum my_enum var:16;
> Hmm, I've never seen that before.  I can't find any description of it in
> K&R.  

I saw this syntax many time ago. It's bit syntax. I used already this
syntax in tds.h to specify bit flags without loosing readiness or
space... You can use this syntax only inside struct/union

> > > With TDS_DYNAMIC, you send the statement text, then *ask* 
> > the server to
> > > describe the i/o parameters (i.e. types).   To execute, you 
> > send TDS_DYNAMIC
> > > again ('type' TDS_DYN_EXEC (0x02)), followed by a bunch of parameter
> > > packets.  Paramater names are not supported.  
> > 
> > I know, but there are problem with image/text field...
> That's a limitation of stored procedures, too.  I think dynamic SQL
> basically creates a stored procedure on the server.  From Sybase's T-SQL
> UG[1]:
> <quote>
> Parameters must be given a system datatype (except text or image) or a
> user-defined datatype, and (if required for the datatype) a length or
> precision and scale in parentheses.
> </quote>

You are right...
1> create proc test @i image as return 12
2> go
Msg 2739, Level 16, State 1, Server , Line 1
TEXT and IMAGE datatypes are invalid for parameters or local variables.

I tried with Sybase ODBC and ethereal... Their odbc version have same
problem. First they try to prepare query, than they ignore raised error
and emulate prepare (just do a "insert into #binary_test
values(0x00..."). Not so good but I can live with.

> The other thing you tried was to send TDS_PARAMFMT packets to the server,
> trying to describe the parameter.  It doesn't work that way.  The server
> sends them to you in response to TDS_DYN_PREPARE.  I assume you knew that,
> and were just trying *anything* to see if you could create image-type
> paramaters.  

Yes, I was just trying anything possible combination :)

My TODO on prepared statement is (I'm at a good point):
- discard token added by dynamic protocol
- handle SQLPutData filling TDSPARAM structure
- add a test for SQLPutData
- test parameters length in query.c

Code is in CVS but it must be enabled with --enable-development


PS: are you working on charset ?

More information about the FreeTDS mailing list