s-news
[Top] [All Lists]

Re: ODBC question

To: <Ita.Cirovic-Donev@hypo-alpe-adria.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: ODBC question
From: "ONKELINX, Thierry" <Thierry.ONKELINX@inbo.be>
Date: Tue, 16 May 2006 17:14:15 +0200
Thread-index: AcZ4+IrKCpchjih2SQWCExVgaKjz4gAASmWw
Thread-topic: [S] ODBC question
The problem is in your sql statement.
Change
sqlQuery="create table TRYTABLE as select * from mytable"
into
sqlQuery=" SELECT * INTO trytable FROM mytable;"

This code worked with my database
Connection <- "DSN=MS
Access-database;DBQ=C:\\path\\to\\database\\mydatabase.mdb;DefaultDir=C:
\\path\\to\\database\\;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;"
sqlStr <- "SELECT * INTO trytable FROM mytable;"
importData(type = "ODBC", stringsAsFactors = T, odbcConnection =
Connection, odbcSqlQuery = sqlStr)

It returns an empty object and creates the table in the database.

Cheers,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx@inbo.be
www.inbo.be
-----Oorspronkelijk bericht-----
Van: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] Namens
Ita.Cirovic-Donev@hypo-alpe-adria.com
Verzonden: dinsdag 16 mei 2006 16:32
Aan: s-news@lists.biostat.wustl.edu
Onderwerp: [S] ODBC question





Hi all,

simple ODBC question. I have been using ODBC to connect to MSAccess
database in R. Now I purchased S-Plus 7 and need to do the same thing.
Can
someone help out in what I am doing wrong. Thanks.

System DSN: mydata
database: mydatabase
table: my table

I run the following code:

finaldata <- importData(type="ODBC", user="me",
password="22222",database="mydatabase",
                  table="mytable", stringsAsFactors=F, bigdata=T)


channel <- "DSN=mydata;UID=me;PWD=22222;DATABASE=mydatabase"

openDBConnection();

executeSQL(type="ODBC", user="me", password="22222",
database="mydatabase",
           odbcConnection=channel, sqlQuery="create table TRYTABLE as
select * from mytable")

closeDBConnection()


First I do get finaldata correctly as big data frame. The table mytable
has
1.5 million rows and 154 columns. The problem is when I want to open the
connection to do SQL commands. The error is

NULL data frame with 0 rows


thanks.

Ita

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • ODBC question, Ita . Cirovic-Donev
    • Re: ODBC question, ONKELINX, Thierry <=