[freetds] dbresults returning no res_info
James K. Lowden
jklowden at schemamania.org
Tue Dec 10 23:51:43 EST 2002
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
More information about the FreeTDS
mailing list