Skip to Content.
Sympa Menu

freetds - RE: [freetds] SQLRowCount failing after prepare and execute

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] SQLRowCount failing after prepare and execute
  • Date: Mon, 16 Feb 2004 14:09:38 -0000

Thanks Freddy - most interesting.

1st interesting thing is the packet we get back from the prepare.
Its like we get the full results back even thogh the stateemnts havent been
executed yet.
It seems to me we should only be ienterested in the DONEPROC and PARAM
tokens from a sp_prepare...

2nd interesting thing. These are the DONEINPROC tokens coming back from
sp_execute () when the prepared statement was

select * from #tmp where i = 2
delete from #tmp

ff 11 00 c1 00 00 00 00 00
ff 11 00 c4 00 01 00 00 00

We have two things that may help us with the DONEINPROC tokens

1) both have the "done_count_valid" bit set.
2) the short token value. I can tell you that

c1 = SELECT
c4 = DELETE

also, FYI...

c3 = INSERT
c5 = UPDATE

Not sure if this helps.

My feeling on this is that after a statement (or batched multiple statements
) have been executed by the server,
the API functions should behave exactly the same to the caller whether the
statement was previously "prepared" or not.

I don't know if this how the MS ODBC driver behaves, and I don't really care
to be honest.

In our example the user should be able to identify, using the API, that
there were two separate statements in the prepared batch, and be able to
access the rowcounts and column counts for each!

Good Luck,

Bill

> -----Original Message-----
> From: ZIGLIO, Frediano, VF-IT [SMTP:Frediano.Ziglio AT vodafone.com]
> Sent: Monday, February 16, 2004 1:20 PM
> To: FreeTDS Development Group
> Subject: RE: [freetds] SQLRowCount failing after prepare and execute
>
> >
> > Freddy,
> >
> > might we be able to use that short on the DONEINPROC to help
> > us (remember the RAISERROR thing ?)
> >
> > If you send me the complete output packet from a prepared
> >
> > "select * from #tmp where i=2 delete from #tmp"
> >
> > and a prepared
> >
> > "delete from #tmp select * from #tmp where i=2"
> >
> > I might be able to find out some values :-)
> >
> > Bill
> >
> >
>
> Ok, this is the code
>
> #include "common.h"
>
> /* Test for SQLPrepare */
>
> static char software_version[] = "$Id$";
> static void *no_unused_var_warn[] = { software_version,
> no_unused_var_warn };
>
> int
> main(int argc, char *argv[])
> {
> Connect();
>
> Command(Statement, "create table #tmp (i int) insert into #tmp
> values(1)");
>
> if (SQLPrepare(Statement, (SQLCHAR *) "delete from #tmp select *
> from #tmp where i=2", SQL_NTS) != SQL_SUCCESS) {
> printf("Unable to prepare statement\n");
> exit(1);
> }
>
> if (SQLExecute(Statement) != SQL_SUCCESS) {
> printf("Wrong result executing statement\n");
> exit(1);
> }
>
> while(SQLMoreResults(Statement) == SQL_SUCCESS);
>
> Disconnect();
>
> printf("Done.\n");
> return 0;
> }
>
> Outputs attached
>
> freddy77 << File: out1.txt.gz >> << File: out.txt.gz >> << File:
> ATT728414.txt >>

==============================================================================

If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.
<http://www.ml.com/email_terms/>

==============================================================================





Archive powered by MHonArc 2.6.24.

Top of Page