freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Brian Bruns <camber AT umcc.ais.org>
- To: TDS Development Group <freetds AT franklin.oit.unc.edu>
- Subject: Re: iodbc and freetds
- Date: Sun, 29 Aug 1999 20:09:04 -0400 (EDT)
Ok...everything is working well then it appears, only the first query
you sent didn't return any rows.
And I think I see the problem. 'use <database>' is the first result set
and returns no rows. the tdstest app is not built to loop on result set,
thus the second query never gets processed.
Now that you know that you have basic connectivity, move to either dblib
or ctlib. The reason is that TDS is a support layer for the other
libraries (the other libraries call libtds). They are more full featured
and have an API that will not change. The libtds library could and
probably will change over time and has pretty minimal features. So
unless you intend on creating a API layer, I'd steer clear of it.
Info on dblib and ctlib is available online at sybooks.sybase.com, and I
believe if you dig around MS's site there is still some dblib info there
as well. Not all of the functions are implemented by FreeTDS, however a
fairly good subset of it is.
Or if you are doing perl, then grab DBD::Sybase or Sybperl and give it a
go. (Sybperl is dblib and ctlib for Perl, DBD::Sybase is a DBI driver
written over ctlib).
Cheers,
Brian
On Sun, 29 Aug 1999 yan AT cbmi.upmc.edu wrote:
> Brian,
>
> Yep. I configured it with --with=tdsver=4.2. I'll try the
> select db_name(). Running the same code I just sent you with only
> changing " tds_submit_query(tds,"select db_name()"); " gives the following
> output:
>
> gmake tdstest
> gcc -DPACKAGE=\"freetds\" -DVERSION=\"0.45\" -DSTDC_HEADERS=1
> -DHAVE_SYS_WAIT_H=1 -DHAVE_UNISTD_H=1 -DRDS_BIGENDIAN=1
> -DHAVE_STRFTIME=1 -I. -I. -I/usr/local/freetds/include -g -O2
> -DHW_LITTLE_ENDIAN -DS42 -c tdstest.c
> /bin/sh ../libtool --mode=link gcc -g -O2 -DHW_LITTLE_ENDIAN -DTDS42 -o
> tdstest tdstest.o debug.o -Lsr/local/freetds/lib -lsocket -ltds
> gcc -g -O2 -DHW_LITTLE_ENDIAN -DTDS42 -o tdstest tdstest.o debug.o
> -L/usr/local/freetds/lib -lsocket -ds
> > ./tdstest
> col 0
> Type: 39
> Name:
> Offset: 1
> col 0 is master
> rc: -2
> > uname -a
> SunOS grill 5.6 Generic sun4m sparc SUNW,SPARCstation-20
>
>
> Again. Thank you so much for your help in this regard. Any tips or
> flaming (in regard to any dumb mistakes on my part) :-) will be happily
> accepted.
>
> Yantiff
>
> On Sun, 29 Aug 1999, Brian Bruns wrote:
>
> >
> > Hmmm...2 is TDS_NO_MORE_RESULTS which is a normal end of processing type
> > of thing. Could you throw a smipler query at it...something like 'select
> > db_name()' and see what happens. Also I'm assuming you configure'd with
> > --with-tdsver=4.2 ?
> >
> > brian
> >
> > On Sun, 29 Aug 1999 yan AT cbmi.upmc.edu wrote:
> >
> > > Brian,
> > >
> > > Sorry about that...
> > > Here it is:
> > >
> > > I modified the code a bit to see what tds_submit_query is
> > > returning; otherwise the program just runs without returning anything.
> > >
> > > > gmake tdstest
> > > gcc -DPACKAGE=\"freetds\" -DVERSION=\"0.45\" -DSTDC_HEADERS=1
> > > -DHAVE_SYS_WAIT_H=1 -DHAVE_UNISTD_H=1 -DWORDS_BIGENDIAN=1
> > > -DHAVE_STRFTIME=1 -I. -I. -I/usr/local/freetds/include -g -O2
> > > -DHW_LITTLE_ENDIAN -DTDS42 -c tdstest.c
> > > /bin/sh ../libtool --mode=link gcc -g -O2 -DHW_LITTLE_ENDIAN -DTDS42
> > > -o
> > > tdstest tdstest.o debug.o -L/usr/local/freetds/lib -lsocket -ltds
> > > gcc -g -O2 -DHW_LITTLE_ENDIAN -DTDS42 -o tdstest tdstest.o debug.o
> > > -L/usr/local/freetds/lib -lsocket -ltds
> > > > ./tdstest
> > > rc: 2
> > >
> > >
> > > #include <stdio.h>
> > > #include <tds.h>
> > >
> > >
> > > static char software_version[] = "$Id: tdstest.c,v 1.5 1999/06/13
> > > 00:07:17 camber Exp $";
> > > static void *no_unused_var_warn[] = {software_version,
> > > no_unused_var_warn};
> > >
> > >
> > > char *value_as_string(
> > > TDSSOCKET *tds,
> > > int col_idx)
> > > {
> > > static char result[256];
> > > const int type = tds->res_info->columns[col_idx]->column_type;
> > > const char *row = tds->res_info->current_row;
> > > const int offset =
> > > tds->res_info->columns[col_idx]->column_offset;
> > > const void *value = (row+offset);
> > >
> > > switch(type)
> > > {
> > > case SYBVARCHAR:
> > > {
> > > strncpy(result, (char *)value, sizeof(result)-1);
> > > result[sizeof(result)-1] = '\0';
> > > break;
> > > }
> > > case SYBINT4:
> > > {
> > > sprintf(result, "%d", *(int *)value);
> > > break;
> > > }
> > > default:
> > > {
> > > strcpy(result, "NotImp");
> > > break;
> > > }
> > > }
> > > return result;
> > > } /* value_as_string() */
> > >
> > >
> > > int main()
> > > {
> > > TDSLOGIN *login;
> > > TDSSOCKET *tds;
> > > int rc;
> > > int i;
> > >
> > > login = tds_alloc_login();
> > > tds_set_passwd(login,"byteme4");
> > > tds_set_user(login,"sa");
> > > tds_set_app(login,"sqsh");
> > > tds_set_host(login,"grill.cis.pitt.edu");
> > > tds_set_library(login,"TDS-Library");
> > > tds_set_server(login,"color");
> > > tds_set_charset(login,"iso_1");
> > > tds_set_language(login,"us_english");
> > > tds_set_packet(login,512);
> > >
> > > if (!(tds = tds_connect(login))) {
> > > fprintf(stderr, "Login Failed!\n");
> > > exit(1);
> > > }
> > >
> > > /* tds_submit_query(tds,"select db_name() dbname, user_name()
> > > username"); */
> > > /* tds_submit_query(tds,"select idx from groups"); */
> > > tds_submit_query(tds,"use pharos select id from users where
> > > id='shaykin'");
> > > rc=tds_process_result_tokens(tds);
> > > if (rc==TDS_SUCCEED)
> > > {
> > > for (i=0; i<tds->res_info->num_cols; i++)
> > > {
> > > printf("col %d\n Type: %d\n Name: %s\n Offset: %d\n",
> > > i,
> > > tds->res_info->columns[i]->column_type,
> > > tds->res_info->columns[i]->column_name,
> > > tds->res_info->columns[i]->column_offset);
> > > }
> > >
> > > while ((rc=tds_process_row_tokens(tds))==TDS_SUCCEED)
> > > {
> > > for (i=0; i<tds->res_info->num_cols; i++)
> > > {
> > > printf("col %i is %s\n", i, value_as_string(tds, i));
> > > }
> > > }
> > > }
> > > printf("rc: %d\n", rc);
> > > return 0;
> > > }
> > >
> > >
> > >
> > > On Sun, 29 Aug 1999, Brian Bruns wrote:
> > >
> > > >
> > > > What kind of error messages or incorrect behaviour are you seeing?
> > > > And on
> > > > which boxes? There are some issues running certain things on Solaris
> > > > (the
> > > > the other message that just went out to the list). Are you trying to
> > > > run
> > > > DBD::Sybase, Sybperl, PHP? Which version of FreeTDS are you running?
> > > > (I
> > > > would highly recomend the snapshot).
> > > >
> > > > Brian
> > > >
> > > > On Sun, 29 Aug 1999 yan AT cbmi.upmc.edu wrote:
> > > >
> > > > > Brian,
> > > > >
> > > > > Thank you for the advice. I am still having the same problem
> > > > > accessing my SQL 6.5 database from my Solaris 2.6 box. I tested
> > > > > the code
> > > > > on my linux box and am having the same problem. I can give you
> > > > > access to
> > > > > the database and if this would help you trace the problem (to the
> > > > > actual
> > > > > sun box). I compiled freetds successfully and ran the samples for
> > > > > tds successfully on my box. Here is the code and the interface
> > > > > configuration I am using:
> > > > >
> > > > > #include <stdio.h>
> > > > > #include <tds.h>
> > > > >
> > > > >
> > > > > static char software_version[] = "$Id: tdstest.c,v 1.5
> > > > > 1999/06/13
> > > > > 00:07:17 camber Exp $";
> > > > > static void *no_unused_var_warn[] = {software_version,
> > > > > no_unused_var_warn};
> > > > >
> > > > >
> > > > > char *value_as_string(
> > > > > TDSSOCKET *tds,
> > > > > int col_idx)
> > > > > {
> > > > > static char result[256];
> > > > > const int type =
> > > > > tds->res_info->columns[col_idx]->column_type;
> > > > > const char *row = tds->res_info->current_row;
> > > > > const int offset =
> > > > > tds->res_info->columns[col_idx]->column_offset;
> > > > > const void *value = (row+offset);
> > > > >
> > > > > switch(type)
> > > > > {
> > > > > case SYBVARCHAR:
> > > > > {
> > > > > strncpy(result, (char *)value, sizeof(result)-1);
> > > > > result[sizeof(result)-1] = '\0';
> > > > > break;
> > > > > }
> > > > > case SYBINT4:
> > > > > {
> > > > > sprintf(result, "%d", *(int *)value);
> > > > > break;
> > > > > }
> > > > > default:
> > > > > {
> > > > > strcpy(result, "NotImp");
> > > > > break;
> > > > > }
> > > > > }
> > > > > return result;
> > > > > } /* value_as_string() */
> > > > >
> > > > >
> > > > > int main()
> > > > > {
> > > > > TDSLOGIN *login;
> > > > > TDSSOCKET *tds;
> > > > > int rc;
> > > > > int i;
> > > > >
> > > > > login = tds_alloc_login();
> > > > > tds_set_passwd(login,"byteme4");
> > > > > tds_set_user(login,"sa");
> > > > > tds_set_app(login,"sqsh");
> > > > > tds_set_host(login,"color");
> > > > > tds_set_library(login,"TDS-Library");
> > > > > tds_set_server(login,"pharos");
> > > > > tds_set_charset(login,"iso_1");
> > > > > tds_set_language(login,"us_english");
> > > > > tds_set_packet(login,512);
> > > > >
> > > > > if (!(tds = tds_connect(login))) {
> > > > > fprintf(stderr, "Login Failed!\n");
> > > > > exit(1);
> > > > > }
> > > > >
> > > > > /* tds_submit_query(tds,"select db_name() dbname, user_name()
> > > > > username"); */
> > > > > /* tds_submit_query(tds,"select idx from groups"); */
> > > > > tds_submit_query(tds,"use pharos select id from users where
> > > > > id='shaykin'");
> > > > > while ((rc=tds_process_result_tokens(tds))==TDS_SUCCEED)
> > > > > {
> > > > > for (i=0; i<tds->res_info->num_cols; i++)
> > > > > {
> > > > > printf("col %d\n Type: %d\n Name: %s\n Offset: %d\n",
> > > > > i,
> > > > > tds->res_info->columns[i]->column_type,
> > > > > tds->res_info->columns[i]->column_name,
> > > > > tds->res_info->columns[i]->column_offset);
> > > > > }
> > > > >
> > > > > while ((rc=tds_process_row_tokens(tds))==TDS_SUCCEED)
> > > > > {
> > > > > for (i=0; i<tds->res_info->num_cols; i++)
> > > > > {
> > > > > printf("col %i is %s\n", i, value_as_string(tds, i));
> > > > > }
> > > > > }
> > > > > }
> > > > > return 0;
> > > > > }
> > > > >
> > > > > Interfaces
> > > > >
> > > > > JDBC
> > > > > query tcp ether 192.138.151.39 4444
> > > > > master tcp ether 192.138.151.39 4444
> > > > >
> > > > > myserver
> > > > > query tcp ether 127.0.0.1 4000
> > > > > master tcp ether 127.0.0.1 4000
> > > > >
> > > > > myserver2
> > > > > query tcp ether 127.0.0.1 4001
> > > > > master tcp ether 127.0.0.1 4001
> > > > > color
> > > > > query tcp ether 136.142.141.13 1433
> > > > > pharos tcp ether 136.142.141.13 1433
> > > > >
> > > > >
> > > > > The password and username will work for testing purposes.
> > > > > The SQL database I am trying to access is pharos and I can access
> > > > > it from
> > > > > my DBI:odbc perl scripts on a win32 platform (configured with
> > > > > odbc32
> > > > > client). Any tips would be profusely welcomed.
> > > > >
> > > > >
> > > > > Yantiff
> > > > >
> > > > > On Sun, 29 Aug 1999, Brian Bruns wrote:
> > > > >
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > The obdc library is extremely alpha quality (if that) right now.
> > > > > > I
> > > > > > wouldn't recommend using it. There is another group that created
> > > > > > an ODBC
> > > > > > driver on top of libtds and we will be merging that back into the
> > > > > > main
> > > > > > library soon instead of the ODBC driver that is presently there.
> > > > > > (The new
> > > > > > one will use unixODBC instead of iODBC for a driver manager).
> > > > > >
> > > > > > I would reccomend using dblib or ctlib for the time being if that
> > > > > > is an
> > > > > > option for you.
> > > > > >
> > > > > > Brian
> > > > > >
> > > > > > On Sun, 29 Aug 1999 yan AT cbmi.upmc.edu wrote:
> > > > > >
> > > > > > > To nay of you that have done this,
> > > > > > >
> > > > > > >
> > > > > > > I compiled the iodbc-2.12.and successfully compiled the
> > > > > > > libtdsodbc.so etc. libraries. However, I cannot find any
> > > > > > > sample code that
> > > > > > > shows me how to use it. Could anyone provide me with simple
> > > > > > > code that
> > > > > > > does freetdsodbc or instructions on how to do so?
> > > > > > >
> > > > > > > Yantiff
> > > > > > >
> > > > > >
> > > > > >
> > > > > > ---
> > > > > > You are currently subscribed to freetds as: yan AT cbmi.upmc.edu
> > > > > > To unsubscribe, forward this message to $subst('Email.Unsub')
> > > > > >
> > > > >
> > > > > ---
> > > > > You are currently subscribed to freetds as: camber AT ais.org
> > > > > To unsubscribe, forward this message to $subst('Email.Unsub')
> > > > >
> > > > >
> > > >
> > > >
> > > > ---
> > > > You are currently subscribed to freetds as: yan AT cbmi.upmc.edu
> > > > To unsubscribe, forward this message to $subst('Email.Unsub')
> > > >
> > >
> > > ---
> > > You are currently subscribed to freetds as: camber AT ais.org
> > > To unsubscribe, forward this message to $subst('Email.Unsub')
> > >
> > >
> >
> >
> > ---
> > You are currently subscribed to freetds as: yan AT cbmi.upmc.edu
> > To unsubscribe, forward this message to $subst('Email.Unsub')
> >
>
> ---
> You are currently subscribed to freetds as: camber AT ais.org
> To unsubscribe, forward this message to $subst('Email.Unsub')
>
>
-
iodbc and freetds,
yan, 08/29/1999
- <Possible follow-up(s)>
- Re: iodbc and freetds, Brian Bruns, 08/29/1999
- Re: iodbc and freetds, yan, 08/29/1999
- Re: iodbc and freetds, Brian Bruns, 08/29/1999
- Re: iodbc and freetds, yan, 08/29/1999
- Re: iodbc and freetds, Brian Bruns, 08/29/1999
- Re: iodbc and freetds, yan, 08/29/1999
- Re: iodbc and freetds, Brian Bruns, 08/29/1999
- Re: iodbc and freetds, yan, 08/30/1999
Archive powered by MHonArc 2.6.24.