[Rd] bug in sqlSave with fast=F option (PR#9429)

paul.macmanus at gmail.com paul.macmanus at gmail.com
Fri Dec 22 19:38:16 CET 2006


Full_Name: Paul MacManus
Version: 2.3.0
OS: Windows XP
Submission from: (NULL) (216.90.169.253)


See also R-help thread for October 18, 2006

---------------------------
Create a dataframe and save it to a database table "test" as follows:

df <- data.frame(T=1, S=10)
sqlSave(channel, df, "test", rownames=F)

The table now looks like

T  S
1  10

If I create another dataframe and save as follows

df <- data.frame(S=20, T=2)
sqlSave(channel, df, "test", rownames=F, append=T)

Then table "test" now looks like

T  S
1  10
2  20

The important point is that although S was the first column of df,
sqlSave checked the column names and matched the corresponding columns
of df and table "test".

However, if I now create another dataframe and save it using the
fast=F option as follows

df <- data.frame(S=30, T=3)
sqlSave(channel, df, "test", rownames=F, append=T, fast=F)

the table test now looks like

T  S
1  10
2  20
30 3

In other words, sqlSave didn't check column names, it simply mapped
column 1 to column 1 and column 2 to column 2.
-------------------------

I'm using R 2.3.0 and package RODBC 1.1-7 on Windows XP with MS SQL Server



More information about the R-devel mailing list