I have found the error using ' dbWriteTable ' and can not find any clue what way to handle it. The error is alike:
Error in .oci.WriteTable(conn, name, value, row.names = row.names, overwrite = overwrite, :
Error in .oci.GetQuery(con, stmt, data = value) : ORA-00913: too many values
I have got the Oracle table of such a structure (the extract from Oracle script):
create table My_table
(
card_id NUMBER(4),
predictor VARCHAR2(1000),
interval NUMBER(4),
attributes VARCHAR2(1000),
scoring NUMBER(20,10),
comments VARCHAR2(1000),
uploaded DATE
)
The dataframe contains only one row and the structure of it as follows (the R outpur of 'str' function - str(x)):
'data.frame': 1 obs. of 7 variables:
$ CARD_ID : int 36
$ PREDICTOR : chr "YEAR"
$ INTERVAL : int 1
$ ATTRIBUTES: chr ">= 1945 < 1960"
$ SCORING : int 7000
$ COMMENTS : chr "no comments"
$ UPLOADED : Date, format: "2016-09-26"
The script to establish connection is as follows:
drv <- dbDriver("Oracle")
con <- dbConnect(drv, user, password, DB_name,bulk_read = rows_at_time)
The script to insert the dataframe into the Oracle table is as follows:
dbWriteTable(con, Oracle_table, My_dataframe, row.names = FALSE, overwrite = FALSE,
append = TRUE, ora.number = TRUE, schema = NULL, date = FALSE
)
So only dbWriteTable generate the following error:
Error in .oci.GetQuery(con, stmt, data = value) : ORA-00913: too many values
The structure of the tables is similar to the dataframe one. The usage with other dataset and other Oracle table seems to be ok but not with this dataframe. I would be glad to hear any hits how to handle this error.
Well, I have found the solution to this error. I have used dbGetQuery(con, script,Oracle_table) . It have worked fine. The script used as follows:
script <- paste("insert into ", user_card_table," values (:1, :2, :3, :4, :5, :6, :7)")
But I wonder why there were an error in dbWriteTable because another script with the similar function had worked fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.