freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "James K. Lowden" <jklowden AT schemamania.org>
- To: freetds AT lists.ibiblio.org
- Subject: Re: [freetds] dbresults returning no res_info
- Date: Tue, 10 Dec 2002 23:51:43 -0500
On Tue, 10 Dec 2002 13:44:09 -0800, "Kaveri, Ramesh"
<ramesh.kaveri AT intel.com> wrote:
> Hi all
>
> I have a linux applications which dumps some data into MSSQL 7.0 through
> FreeTDS. I have a problem with dbresults. The problem is - dbresults
> returns no res_info. I am supposed to get num_cols as 1, but it returns
> as 0.
>
> Here is the piece of code that I have:
>
>
> if(*legosQuery)
> {
> if (dbcmd(dbproc,legosQuery) != SUCCEED) {
> printf("dbcmd failed\n");
> }
>
> if (dbsqlexec(dbproc) != SUCCEED)
> {
> printf("dbsqlexec failed\n");
> }
> printf("After dbsqlexec\n");
>
> if (dbresults(dbproc) != FAIL) {
> TDSRESULTINFO *ResInfo;
> TDSSOCKET *Tds;
> Tds = (TDSSOCKET*)dbproc->tds_socket;
> ResInfo = Tds->res_info;
> if(ResInfo)
> printf (">numcols: %d \n",ResInfo->num_cols);
Ramesh,
You're working too hard. :)
Look up dbnextrow() and either dbbind() or dbdata(). Those are the db-lib
functions to read result set data. Sybase's documentation includes brief
examples.
You should treat the dbproc as opaque. There's no guarantee its structure
won't change; it's really just a handle to the session. The above code is
certainly nonportable, an is likely to break with the next release (if it
didn't already).
HTH.
--jkl
-
[freetds] dbresults returning no res_info,
Kaveri, Ramesh, 12/10/2002
- Re: [freetds] dbresults returning no res_info, James K. Lowden, 12/10/2002
- <Possible follow-up(s)>
- RE: [freetds] dbresults returning no res_info, ZIGLIO Frediano, 12/11/2002
Archive powered by MHonArc 2.6.24.