Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

dput(head(dat,10))

structure(list(DATE = c("14-04-2013 00:02:30", "14-04-2013 00:03:00", 
"14-04-2013 00:03:30", "14-04-2013 00:04:00", "14-04-2013 00:04:30", 
"14-04-2013 00:05:00", "14-04-2013 00:05:30", "14-04-2013 00:06:00", 
"14-04-2013 00:06:30", "14-04-2013 00:07:00"), LPAR = c("server1", 
"server1", "server1", "server1", "server1", 
"server1", "server1", "server1", "server1", 
"server1"), ENT = c("0.50", "0.50", "0.50", "0.50", "0.50", 
"0.50", "0.50", "0.50", "0.50", "0.50"), USR_SYS_CPU_PCT = c(73L, 
74L, 75L, 75L, 72L, 73L, 74L, 75L, 75L, 74L), ENT_PCT = c(345.6, 
397.7, 394.2, 418.6, 349.2, 358.9, 585.7, 443.8, 464.9, 483.1
), PHYSICAL_CPU_USED = c(1.73, 1.99, 1.97, 2.09, 1.75, 1.79, 
2.93, 2.22, 2.32, 2.42)), .Names = c("DATE", "LPAR", "ENT", "USR_SYS_CPU_PCT", 
"ENT_PCT", "PHYSICAL_CPU_USED"), row.names = c(NA, 10L), class = "data.frame")    

I am trying to insert dat data frame to an existing oracle table called VMSTAT. I am doing to this insert:

library(RODBC)
ch=odbcConnect("<dsn name>",pwd = "<password>")
sqlSave(ch,dat, tablename="VMSTAT",append=T)
odbcClose(ch)

not working. My R session is crashing. The VMSTAT table has the same column names as the data frame. Has anybody try to insert data frames to Oracle table, any help is really appreciated?

share|improve this question
    
You are missing an end quote at the end of that second line: pwd = "<password>). Is that a typo from copying and pasting onto the site or is it in your code? –  David Robinson Apr 15 '13 at 14:48
    
yes, it is the copy paste problem. that's not it. –  user1471980 Apr 15 '13 at 14:50
    
Is T a valid synonym for TRUE in the append argument? (I have no idea... just looks a bit odd) –  Alex Poole Apr 15 '13 at 15:43
    
@Alex Poole, when I take out the append option, I get VMSTAT table already exists error. –  user1471980 Apr 15 '13 at 15:47
    
I wasn't querying whether append was OK, it was whether it should be append=TRUE rather then append=T (as the manual suggests, maybe). –  Alex Poole Apr 15 '13 at 15:50

1 Answer 1

up vote 1 down vote accepted

I found out what the problem was. My DATE field on oracle table is as DATE but on the data frame was a character. I had to use:

dat$DATE<-as.POSIXct(dat$DATE, format="%d-%m-%Y %H:%M:%S")

and it worked.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.