Skip to Content.
Sympa Menu

freetds - RE: [freetds] Stored Procs and MS SQL Server

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] Stored Procs and MS SQL Server
  • Date: Thu, 4 Dec 2003 15:24:51 -0000

David,

You didn't undertand what I said....

Your fetch loop will return CS_END_DATA when it has fetched all the ROWS OF
DATA associated with the first result set of your command, but it doesn't
finish reading all the RESULTS.
To do that you have to call ct_results until it returns CS_END_RESULTS.

And YES YOU CAN execute a stored proc as a simple CS_LANG_CMD
That's not your problem. Your problem is the previous query you've not
processed correctly.

If you're code is quite small, send it to me and I'll re-code it correctly
for you... now there's an offer!

Bill

> -----Original Message-----
> From: David Nsengiyumva [SMTP:davidn AT finsolutions.co.za]
> Sent: 04 December 2003 15:15
> To: freetds AT lists.ibiblio.org
> Subject: [freetds] Stored Procs and MS SQL Server
>
> >>Hey david,
> >>
> >>your problem is that you haven't fully processed the result set from
> your
> >>previous command that is accessing sysobjects, syscolumns etc.
> >>
> >>
> >>You are doing a ct_results() and then a ct_fetch(), but you haven't
> fully
> >>processed the result set before issuing your "exec stored proc" command.
> >>You need to call ct_results in a loop until it returns CS_END_RESULTS
> >>
> >>see <freetds>/src/ctlib/unittests/t0002.c for an example of a ct_results
> >>loop.
> >>
> >>The CS_RECOMPILE options will force the stored procedure to be
> recompiled
> >>before executing.
> >>
> >>Bill
>
> Hi Bill,
>
> But my loop looks like this and I think it should work:
>
> do
> {
> // where addRow() is a function that uses the 'ct_describe' and
> // 'ct_bind' to get the fields and add a row in a C++ Row object
> AddRow();
>
> ret = ct_fetch(FTDS->cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count);
> }
> while((ret == CS_SUCCEED));
>
> switch ((int) ret)
> {
> case CS_END_DATA:
> break;
> case CS_ROW_FAIL:
> throw Exception("ct_fetch() returned CS_ROW_FAIL.");
> case CS_FAIL:
> throw Exception("ct_fetch() returned CS_FAIL.");
> default:
> throw Exception("ct_fetch() unexpected return.");
> }
>
> This should basically exit when it has fetched all the result set.
> But my problem is that it when I try to execute a second query then
> the 'tds_submit_query'(in query.c file) it says that 'tds->state =
> TDS_PENDING'.
>
> I DON'T UNDERSTAND WHAT SEEMS TO THE PROBLEM!!!!
>
> Can really anyone tell me if it is possible to execute a stored proc as a
> simple
> CS_LANG_CMD...I mean if one can get the query into the format:
>
> exec stored_proc_name @param1=value1, @param2=value2, etc
>
> Can you then send it as a CS_LANG_CMD ????
>
> Thanx a lot 4 ur help...Very much appreciated
>
> David Nsengiyumva
>
> Software Developer
> Tel: +27 21 464 7215
> Cel: +27 73 351 3975
> Fax: +27 21 464 7201
> http://www.finsolutions.co.za
>
> CONFIDENTIALITY CAUTION
> This page and any accompanying documents contain privileged and
> confidential
> information for the specific individual to whom it is addressed, and are
> protected by law. If the reader is not the intended recipient, you are
> hereby notified that any review, dissemination, distribution or copying or
> the taking of any action based on the contents of this communication is
> strictly prohibited. If you have received this communication in error,
> please desist from reading the contents, notify us immediately and destroy
> the communication.
>
>
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page