Skip to Content.
Sympa Menu

freetds - [freetds] how to CALL Sql stored procedure with C?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Knygh, Øyvind" <oyvind.knygh AT brreg.no>
  • To: "'freetds AT lists.ibiblio.org'" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] how to CALL Sql stored procedure with C?
  • Date: Fri, 3 Oct 2003 13:21:29 +0200

I have problems using function dbhasretstat() and dbretstatus().
Here is the db-lib code in C using FreeTDS. What's wrong with this?? I get
no info from dbretstatus(). I call this stored procedure several times. The
first time it looks like dbhasretstat(dbproc) = FALSE why?
When I'm using result set from the stored procedure all is ok.

dbfcmd (dbproc, " exec oko_chk_apar_id @apar_id=%ld,",apar_id); /*
Kundenr */
dbcmd (dbproc, " @apar_type='R',"); /*
Reskontrotype */
dbfcmd (dbproc, " @client='%s'",client); /* Firma
*/
if (dbsqlexec (dbproc) == FAIL)
{
printf ("Feil i SQL-query. - exec oko_chk_apar_id
@apar_id=%ld,\n",apar_id);
printf (" @apar_type='R',\n");
printf ("
@client='%s'\n",client);
return(-1);
}
while ((result_code = dbresults(dbproc)) != NO_MORE_RESULTS)
{
if (result_code == SUCCEED)
{
dbbind(dbproc, 1, INTBIND, (DBINT) 0, (BYTE *) &status2);
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{

printf("\nStep 2 Sjekk_Acuheader Inne i dbresults
status2=%ld\n",status2);
}

if ( dbhasretstat(dbproc) )
{
status=dbretstatus(dbproc);
if (status==1)
{
return 1; /* Kunde finnes ikke i AGRESSO */
}
else if (status == 0 )
{
return 0; /* Kunde finnes i AGRESSO */
}
else if (status < 0) /* Noe feilet */
{
printf ("Feil, dbhasretstat: status=%ld\n",status);
return (-1);
}
}
if (status2==1)
{
return 1; /* Kunde finnes ikke i AGRESSO */
}
else if (status2 == 0 )
{
return 0; /* Kunde finnes i AGRESSO */
}
}
else
{
printf ("Results Failed\n");
break;
}
}


Øyvind




Archive powered by MHonArc 2.6.24.

Top of Page