Skip to Content.
Sympa Menu

freetds - RE: [freetds] Using sp_executesql with Microsoft SQL Server 2000

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Using sp_executesql with Microsoft SQL Server 2000
  • Date: Wed, 2 Jul 2003 09:46:29 -0400

> From: Rogers, Tom [mailto:tom.rogers AT ccur.com]
> Sent: July 1, 2003 9:04 AM
> To: 'FreeTDS Development Group'
> Subject: RE: [freetds] Using sp_executesql with Microsoft SQL Server
> 2000
>
> Up until about a month ago, we were told by several on this group that
> FreeTDS would not support output parameters on MS SQL because
> of a change
> Microsoft made in the way it handled output params, circa SQL
> 7.0, SPx. At
> that time, they changed the output params such that they were
> being sent
> "out of band" and not part of the normal messages returned
> (or something like that).

Let me try to clarify that. :-)

Nick Castellano discovered that as of SQL Server 7.0 SP3, using TDS 7.0,
Microsoft stopped supporting output parameters embedded in SQL text. If you
sent

declare @a int
exec a @a output

prior to SP3, the server sent a special result set packet. With db-lib, the
application would call dbnumrets() and friends to fetch the output.
Starting with SP3, Microsoft simply ceased sending that special result set
packet; the same application would be told there were no output parameters
returned.

The remedy lay in the RPC protocol, which Frediano had begun to work on for
a different purpose, for placeholder support. In short order we were able
to add the db-lib and ct-lib RPC functions. If they're used, the server
will once again return the data. There are unit tests for both:

src/ctlib/unittests/rpc_ct_param.c
src/ctlib/unittests/rpc_ct_setparam.c
src/dblib/unittests/rpc.c
src/dblib/unittests/t0022.c

Microsoft's own db-lib uses TDS 4.2, which is unaffected. I'm not familiar
enough with the ODBC idiom to know whether or not it has any non-RPC way to
retrieve output parameter values. Perhaps the change affected no Microsoft
customers.

> query = "{? = call mysp(?, ?, ?}"

>From reading the ChangeLog, I doubt you can fetch output parameters that way
yet, but it looks close.

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page