本文介绍了无法将数据帧插入到现有的oracle表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dput(head(dat,10))

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")

我试图将dat数据帧插入到称为VMSTAT的现有oracle表中.我正在执行此插入操作:

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)

不起作用.我的R会话崩溃了. VMSTAT表具有与数据框相同的列名.有没有人尝试将数据帧插入Oracle表,真的有什么帮助吗?

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?

推荐答案

我发现了问题所在.我在oracle表上的DATE字段与DATE一样,但在数据框上是一个字符.我必须使用:

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")

它奏效了.

这篇关于无法将数据帧插入到现有的oracle表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 14:48