I'm executing SQL using RPostgreSQL and sqldf packages.
Connection:
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="dbname",host="host",port=5432,user="usr",password="pwd")
Then I build a pretty complex SQL statement and at the end I have (vSQL
is the SQL select statement):
vSQLDF <- sqldf(vSQL, connection=con)
Now I get the following error:
Error in dbPreExists && !overwrite : invalid 'x' type in 'x && y'
I was not able to create any reproducible example, all I can say is:
- The generated SQL statement works when executed directly in the database (I've copied the string from R to pgAdmin)
- The connection works, I can use
sqldf("select * from any_table, connection=con")
- It works when I generate shorter SQL using different input parameters for my script
- The SQL length only is not a problem, I've tried:
inSQL = paste(rep("select 1::int ",10000),collapse=" union all ")
, which results in different error:RS-DBI driver: (could not Retrieve the result : ERROR: stack depth limit exceeded
- There are no strange characters in my SQL statement
Any idea what this error means?
Session info:
> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=cs_CZ.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=cs_CZ.UTF-8 LC_MONETARY=en_GB.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] tcltk stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-13 sqldf_0.4-6.4 RSQLite.extfuns_0.0.1 RSQLite_0.11.2 chron_2.3-43 gsubfn_0.6-5
[7] proto_0.3-10 RPostgreSQL_0.3-3 DBI_0.2-5
loaded via a namespace (and not attached):
[1] grid_2.15.2 tools_2.15.2
PostgreSQL:
PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit
RStudio 0.97.332