Skip to Content.
Sympa Menu

freetds - RE: [freetds] big commit: language command variable support added

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] big commit: language command variable support added
  • Date: Fri, 7 Mar 2003 15:08:37 -0000

Freddy,

I think I've figured out (almost) sp_prepare, sp_unprepare and sp_execute
from the first link that you provided.

Try this in query analyzer:

<<preptest.txt>>
I think we ought to able to combine this knowledge with the TDS 7 RPC
protocol to give us a solution...

Bill



> -----Original Message-----
> From: ZIGLIO Frediano [SMTP:Frediano.Ziglio AT vodafoneomnitel.it]
> Sent: 07 March 2003 14:25
> To: 'FreeTDS Development Group'
> Subject: RE: [freetds] big commit: language command variable support
> added
>
> >
> > At 7:59 AM +0100 3/7/2003, Frediano Ziglio wrote:
> > >Why BITN are treated like numeric? Does ct_convert ignore destination
> > >length for fixed types?
> >
> > Yes. Pretty much every ctlib function is suppose to ignore
> > destination lengths for fixed types.
> >
>
> Yes, I didn't read early your ct_bind mail...
>
> > >Also, to support the same on TDS7/8: use mix prepare and execute code
> > >and call sp_prepexec RPC (it do something like sp_prepare,
> > sp_execute,
> > >sp_unprepare), see code in query.c.
> >
> > The links you sent on sp_executesql seem like the best solution. I
> > was looking at changing the sql to include declare and sets for each
> > variable, but that is a much better solution. More of a pain than
> > what Sybase offers, but it should be workable.
> >
>
> I started coding (in CVS)
> I don't know if my implementation is correct...
> For example this call should work?
>
> query: "SELECT * FROM xxx WHERE name = @myname"
> param[0]: name:"@myname" data:"test"
>
> Perhaps I supposed query like:
>
> query: "SELECT * FROM xxx WHERE name = ?"
> param[0]: no-name data:"test"
>
> Have I mixed params and placeholder code?
>
> freddy77
>
> =================================
> "STRICTLY PERSONAL AND CONFIDENTIAL
>
> This message may contain confidential and proprietary material for the
> sole
> use of the intended recipient. Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient please contact
> the sender and delete all copies.
> The contents of this message that do not relate to the official business
> of
> our company shall be understood as neither given nor endorsed by it."
>
> =================================
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
create table preptest (col1 int, col2 char(4))

insert into preptest values (1, 'AAAA')
insert into preptest values (2, 'BBBB')

/* first try */

declare @stmt_handle integer
exec sp_prepare @stmt_handle output, N'@p2 char(4)', N'select * from preptest
where col2 = @p2' , 1

select @stmt_handle

exec sp_execute @stmt_handle, 'AAAA'

exec sp_unprepare @stmt_handle

/* second try */

declare @stmt_handle integer
exec sp_prepare @stmt_handle output, N'@p1 int', N'select * from preptest
where col1 = @p1' , 1

select @stmt_handle

exec sp_execute @stmt_handle, 1

exec sp_unprepare @stmt_handle

/* third try */

declare @stmt_handle integer
exec sp_prepare @stmt_handle output, N'@p1 int, @p2 char(4)', N'select * from
preptest where col1 = @p1 and col2 = @p2' , 1

select @stmt_handle

exec sp_execute @stmt_handle, 1, 'AAAA'

exec sp_unprepare @stmt_handle




Archive powered by MHonArc 2.6.24.

Top of Page