Skip to Content.
Sympa Menu

freetds - [freetds] Stored Procs and MS SQL Server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "David Nsengiyumva" <davidn AT finsolutions.co.za>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Stored Procs and MS SQL Server
  • Date: Thu, 4 Dec 2003 17:14:52 +0200

>>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.







Archive powered by MHonArc 2.6.24.

Top of Page