Re: FreeTDS dbwillconvert discrepancy

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <1227951479.7468.13.camel@freddy>
Il giorno mer, 26/11/2008 alle 12.56 -0500, Joe Losco ha scritto:
> Hello all,
> I'm in the process of writing an application for OS X using FreeTDS and 
> objective c.  I have come to a point however, that I am pretty confused. 
> My application at this point is still using the sample provided with 
> FreeTDS as in http://www.freetds.org/userguide/samplecode.htm but I am 
> beginning to convert it to be part of a GUI application in Cocoa. 
> 
> I first used the sample to make sure that I can use it as shown, and 
> with a specific query.  The sample as shown works completely.  I took 
> the same code and with minor modifications put it into the GUI app and 
> it does not work.  Now to give some more detailed information. 
> 
> My problem that I've narrowed it down to is with this stub of code
> if (SYBCHAR != pcol->type) {           
>                 pcol->size = dbwillconvert(pcol->type, SYBCHAR);
>             }
> 
> I've placed  "printf("name:%s type:%d size:%d\n", pcol->name, 
> pcol->type, pcol->size);" around this piece of code so that I can see 
> the before and after effects.  In the command line pure C application 
> dbwillconvert returns the size of the would be data converted to the 
> correct type.  This then lets the memory be allocated properly in the 
> later calloc that uses pcol->size+1, as well as everything else to work 
> as intended. 
> 
> However, in the Objective C/GUI version it appears to return a Bool.  It 
> seems to return 1 if it is convertable and 0 if it is not.  This 
> obviously messes up the rest of the allocations in the sample resulting 
> in truncation and overflow errors.  I then looked into this farther and 
> found http://www.freetds.org/reference/a00275.html#ga24 which from what 
> I can tell is that the desired effect of that function is to return the 
> bool. 
> 
> I'm not sure where to go to look for any more information.  Any advice 
> is greatly appreciated.
>            

It returns a bool, you could see vendors (Sybase or MS) documentation
(ie
http://manuals.sybase.com/onlinebooks/group-cnarc/cng1110e/dblib/@ebt-link;pt=2814?target=%25N%15_45151_START_RESTART_N%25)

freddy77
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.