Skip to Content.
Sympa Menu

freetds - Future implementation

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: FreeTDS <freetds AT franklin.oit.unc.edu>
  • Subject: Future implementation
  • Date: 21 Sep 2002 18:39:35 +0200


Andrea is working on ODBC for best implementation of prepared query.

So I starting viewing his code and do some work with ethereal (packet
sniffer)...

It seem that all implementation (Sybase and all mssql versions) use RPC
for dynamic query. So I think is best to implement first RPC on libtds,
then start with dynamic query.

The most portable way to implement RPC is to use an old form accepted
bye all sql server version. For implementation see TDS_RPC token on
Sybase manual, remove command token (0xE0) and length and put all RPC in
a TDS_BUF_RPC(3) header. Something like

000001B2 03 01 00 bc 00 00 01 00
0a 00 73 00 70 00 5f 00 ...ΒΌ......s.p._.
000001C2 70 00 72 00 65 00 70 00
61 00 72 00 65 00 00 00 p.r.e.p.a.r.e...
000001D2 00 01 26 04 00 00 00 63
2e 00 00 00 2e 00 00 00 ..&....c........
000001E2 40 00 50 00 31 00 20 00
69 00 6e 00 74 00 2c 00 @.P.1. .i.n.t.,.
000001F2 40 00 50 00 32 00 20 00
76 00 61 00 72 00 63 00 @.P.2. .v.a.r.c.
00000202 68 00 61 00 72 00 28 00
32 00 30 00 29 00 00 00 h.a.r.(.2.0.)...
00000212 63 4c 00 00 00 4c 00 00
00 49 00 4e 00 53 00 45 cL...L...I.N.S.E
00000222 00 52 00 54 00 20 00 49
00 4e 00 54 00 4f 00 20 .R.T. .I.N.T.O.
00000232 00 23 00 74 00 65 00 73
00 74 00 28 00 61 00 2c .#.t.e.s.t.(.a.,
00000242 00 62 00 29 00 20 00 56
00 41 00 4c 00 55 00 45 .b.). .V.A.L.U.E
00000252 00 53 00 28 00 40 00 50
00 31 00 2c 00 40 00 50 .S.(.@.P.1.,.@.P
00000262 00 32 00 29 00 00 00 38
01 00 00 00 .2.)...8 ....

Also we should implement input and output parameters,
TDS_RETURNSTATUS/TDS_RETURNVALUE and perhaps TDS_PARAMFMT/TDS_PARAMS.

How to handle dynamic query in Sybase is quite implemented and for mssql
see these two documents
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_p_3ysl.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql7/html/sqlquerproc.asp
(they use RPC, not particulary tokens...)

ODBC (I don't know other api) have a function to return parameter type
for dynamic query. This function is quite easy to implement on Sybase
(Sybase return all parameter type) while hard on mssql, requiring
parsing of query and get manually type of pararameters, see at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_odbc_d_1not.asp

Comments and help of any type are welcome!

freddy77

PS: It seem that i18n thread on ML is dead...
PPS: I know, I should be over the Alps, don't remember me bad things...






Archive powered by MHonArc 2.6.24.

Top of Page