From f.hahne at dkfz-heidelberg.de  Mon Sep  5 09:51:18 2005
From: f.hahne at dkfz-heidelberg.de (Florian Hahne)
Date: Mon, 05 Sep 2005 09:51:18 +0200
Subject: [Rd] RODBC and 64 bit
Message-ID: <1125906678.7238.20.camel@snoopy.inet.dkfz-heidelberg.de>

Hi all,
I was quite succesfully working with the RODB package on a 32 bit linux
box to connect to a MSSQL Server via the freeTSL driver. After changing
to a 64 bit environment I ran into some segmentation faults using
function sqlUpdate on large database operations (the actual seg faults
occured in the call to the C function ODBCUpdate).
I just briefly looked into the code and found some extensive type
casting going on so I figured this might be a 64 bit problem with the
'SQL_C_SLONG' and 'SQL_C_DOUBLE' data types. However I can't rule out
the possibility that my TSL driver is messing up some things. I also
tried to reproduce the error with dummy data but here everything seems
to be fine (this might not be big eneugh). 
As a quick solution I tried using the option fast=FALSE, but again ran
into problems, this time R related:
The code lines

 cc <- grep("char", tolower(as.character(cdata[, 6])))
        if (length(cc))
            data[, cc] <- paste("'", data[, cc], "'", sep = "")

look up the columns with character data types from the database
specifications and includes parantheses that are later necessary for the
SQL query. This works fine as long as you are updating all database
columns. However if you only update a subset this will identify the
wrong columns in you data frame as being character. Something along the
lines of  

 cc <- grep("char", tolower(as.character(cdata[match(cnames,
            cdata[, 4]), 6])))
        if (length(cc))
            data[, cc] <- paste("'", data[, cc], "'", sep = "")

should fix that problem.
Hope anybody has an idea about the memory issue, since the fast=FALSE
option does exactly what its name suggests ;-)

Florian

     
-- 
Florian Hahne
Molecular Genome Analysis (B050)
German Cancer Research Center
Im Neuenheimer Feld 580
D-69120 Heidelberg
Germany
room TP3 2.204
phone ++49 6221 42-4764
email f.hahne at dkfz.de



[Rd] RODBC and 64 bit
Florian Hahne