freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
RE: [freetds] how to CALL Sql stored procedure with C?
- From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
- To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] how to CALL Sql stored procedure with C?
- Date: Fri, 3 Oct 2003 13:05:52 +0100
Hi,
the db-library manual page is slightly ambiguous and confusing on this
point,
and I'm not sure that freeTDS behaves exactly like Sybase or SQl server
db-lib in this respec.t
Using Freetds though, it is not valid to call dbhasretstat until you have
processed all the results using dbresults()
In other words, you should move those calls after the "while...dbresults"
loop
BIll
> -----Original Message-----
> From: "Knygh, Øyvind" [SMTP:oyvind.knygh AT brreg.no]
> Sent: 03 October 2003 12:21
> To: 'freetds AT lists.ibiblio.org'
> Subject: [freetds] how to CALL Sql stored procedure with C?
>
> 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
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] how to CALL Sql stored procedure with C?,
Knygh, Øyvind, 10/03/2003
- Re: [freetds] how to CALL Sql stored procedure with C?, James K. Lowden, 10/03/2003
- <Possible follow-up(s)>
- RE: [freetds] how to CALL Sql stored procedure with C?, Thompson, Bill D (London), 10/03/2003
Archive powered by MHonArc 2.6.24.