0

Despite several efforts I do not succeed to read my tables in an open office database in R.

I have loaded the ODB package. And connect using the command

con <- odb.open('Database.odb')

to connect when i use the command

odb.tables(con)

The console shows me the following

$Datasets
    field.name field.type data.type comment
1           ID    INTEGER   numeric    <NA>
2 Dataset_naam    VARCHAR character    <NA>
3 Beschrijving    VARCHAR character    <NA>
4     Eigenaar    VARCHAR character    <NA>
5      Cluster       CHAR character    <NA>
6   Vindplaats    VARCHAR character    <NA>

Looks promising, however when I try to actually acces the table like this

odb.read(con, 'SELECT * FROM Datasets')

the following error is thrown.

Error: Error while executing SQL query  : "Unable to retrieve JDBC `result set for SELECT * FROM Datasets (Table not found in statement [SELECT * FROM Datasets])"`

Why can I not acces the table?

On the other hand if I try to create tables They do not show when I open the open office database.

Any advise would be greatly appreciated.

Daan
  • 349
  • 4
  • 16
  • What library are you using? Please include all library lines. – Parfait Jan 22 '17 at 20:57
  • It looks like you need to use double quotes around the name of the table in the SELECT statement. – fredt Jan 22 '17 at 20:58
  • I use the ODB package. (This automatically loads DBI, rJava and RJDBC). But fredt is right! is needed to use the double quotation (I used both single quatation and not quoatation). I deeply appreciate your awnsers, I'm really glad that I can at last connect to my database! – Daan Jan 23 '17 at 22:10

2 Answers2

1

You must write the name of a table. Try the following:

odb.read(con, 'SELECT * FROM Cluster')

JJJ
  • 1,009
  • 6
  • 19
  • 31
  • You answer is an exact replica of what the OP said they tried. How is `odb.read(con, 'SELECT * FROM Cluster')` different from `odb.read(con, 'SELECT * FROM Datasets')`? – Wil Apr 14 '19 at 19:58
  • I'm sorry. I make a mistake – user11360138 Apr 15 '19 at 13:51
-1

You should try this...

print(odb.read(con, "SELECT * FROM Datasets"))