Skip to Content.
Sympa Menu

freetds - RE: [freetds] state of dbrpcsend()

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] state of dbrpcsend()
  • Date: Thu, 10 Jun 2004 09:26:14 +0100

Hi again Liam,

I've tried this out, and it works.

here's my C program (databases, logins etc XXXXX'd out)

#include <stdio.h>
#include <sybfront.h>
#include <sybdb.h>

int err_handler();
int msg_handler();

main(argc, argv)
int argc;
char *argv[];
{
DBPROCESS *dbproc;
LOGINREC *login;

RETCODE result_code;
DBINT highest, lowest, ret_stat;

if (dbinit() == FAIL)
exit(1);

dberrhandle((EHANDLEFUNC)err_handler);
dbmsghandle((MHANDLEFUNC)msg_handler);

login = dblogin();
DBSETLUSER(login,"XXXXXXXX");
DBSETLPWD(login, "XXXXXXXX");
DBSETLAPP(login, "XXXXXXXX");

highest = 10;
lowest = 2;

dbproc = dbopen(login, NULL);

dbuse(dbproc,"XXXXXXXXXXX");

dbrpcinit(dbproc, "dbo.sp_freetds_test", 0);

dbrpcparam(dbproc, "@lowest", 0, SYBINT4, -1, -1,
(BYTE *) &lowest);
dbrpcparam(dbproc, "@highest", 0, SYBINT4, -1, -1,
(BYTE *) &highest);

dbrpcsend(dbproc);

while ((result_code = dbresults(dbproc)) != NO_MORE_RESULTS)
{
printf("dbresults returns (%d) \n", result_code);
}
printf("dbresults returns (%d) \n", result_code);

if (dbhasretstat(dbproc) == TRUE) {
ret_stat = dbretstatus(dbproc);
printf("sp return status %d\n", ret_stat);
}

dbexit();
exit(0);
}

int err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr)
DBPROCESS *dbproc;
int severity;
int dberr;
int oserr;
char *dberrstr;
char *oserrstr;
{
if ((dbproc == NULL) || (DBDEAD(dbproc)))
return(INT_EXIT);
else
{
fprintf (stderr, "DB-Library error:\n\t%s\n", dberrstr);

if (oserr != DBNOERR)
fprintf (stderr, "Operating-system error:\n\t%s\n", oserrstr);

return(INT_CANCEL);
}
}


int msg_handler(dbproc, msgno, msgstate, severity, msgtext,
srvname, procname, line)

DBPROCESS *dbproc;
DBINT msgno;
int msgstate;
int severity;
char *msgtext;
char *srvname;
char *procname;
int line;

{
fprintf (stderr, "Msg %ld, Level %d, State %d\n",
msgno, severity, msgstate);

if (strlen(srvname) > 0)
fprintf (stderr, "Server '%s', ", srvname);
if (strlen(procname) > 0)
fprintf (stderr, "Procedure '%s', ", procname);
if (line > 0)
fprintf (stderr, "Line %d", line);

fprintf (stderr, "\n\t%s\n", msgtext);

return(0);
}

and my stored proc :


1> create proc dbo.sp_freetds_test (@lowest int, @highest int)
2> as
3> begin
4> declare @difference int
5> select @difference = @highest - @lowest
6> return @difference
7> end
8>
9>
1> grant exec on dbo.sp_freetds_test to XXXXXXXX
2>

and my output when running the program :

Msg 5701, Level 0, State 2
Server 'XXXXXXXX',
Changed database context to 'master'.
Msg 5703, Level 0, State 1
Server 'XXXXXXXX',
Changed language setting to us_english.
Msg 5701, Level 0, State 1
Server 'XXXXXXXX', Line 1
Changed database context to 'XXXXXXXXXXXX'.
dbresults returns (1)
dbresults returns (2)
sp return status 8

Which database are you using ? I presume SQL server 2000
check your TDS VERSION is correct in the freetds.conf file.
This should be 7.0 or 8.0 for SQL 2K, e.g.

tds version = 7.0

HTH,

Bill



> -----Original Message-----
> From: liam AT inodes.org [SMTP:liam AT inodes.org]
> Sent: 10 June 2004 02:08
> To: FreeTDS Development Group
> Subject: Re: [freetds] state of dbrpcsend()
>
> On Wed, Jun 09, 2004 at 03:16:19PM +0100, Thompson, Bill D (London) wrote:
>
> > to make the C code match your sp you'd have to omit the third call to
> > dbrpcparam() and capture the return status with the appropriate calls
> > to
> > dbresults, dbhasretstat and dbretstatus
>
> Thanks for your response.
>
> I've changed the code to call dbrpcparam() twice only but it still fails
> in dbrpcsend(). Again, it never reaches the wire. Given that it doesn't
> touch the wire after dblogin() is called, would it even matter if I had
> my arguments specified incorrectly? It appears something is amiss inside
> dbrpcsend().
>
> Suggestions?
>
> I might go and compile FreeTDS and dblib with -g and see what's going
> on.
>
> Cheers.
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

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

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