[R] Creating Volatile Table in Teradata using RODBC
John Smith
jSmith.Coursera at outlook.com
Sun Feb 15 10:48:56 CET 2015
Hi All
I'm trying to use R to create a temporary table in Teradata and then add
rows from data frame into the temporary volatile table in R
Based on the code below (I have changed the SQL slightly), I am able to
create the temporary table in my spool space but when I try add the data
frame mydata to it, R tells me it cannot find the table
My assumption here is that it is looking for the "real" table as opposed to
the temp table in spool space. Can anyone see the problem?
# RShowDoc("teradataR", package="teradataR") - Manual
#RShowDoc("RODBC", package="RODBC")
library(RODBC)
library(teradataR)
# Import Data From Text File and remove duplicates
mydata = read.table("c:/Users/user/Desktop/ Keys.txt")
mydata.unique = unique(mydata)
# Create SQL for Temp Table in Teradata
strSQL.TempTable = "CREATE VOLATILE TABLE TEMP_Keys (keys VARCHAR (39))
UNIQUE PRIMARY INDEX(key) ON COMMIT PRESERVE ROWS;"
# Connect To Teradata DB
channel <- odbcConnect('DB')
# Execute Temp Table
sqlQuery(channel, paste(strSQL.TempTable))
sqlUpdate(channel, mydata, tablename = "TEMP_Keys", fast = TRUE)
Any Help would be greatly appreciated
KEYWORDS: Volatile, SQL, R, RODBC, teradataR
REF:
http://stackoverflow.com/questions/24740751/error-with-creating-volatile-tab
le-in-teradata
[[alternative HTML version deleted]]
More information about the R-help
mailing list