使用RODBC軟件包的功能,我成功創建了一個ODBC,但在嘗試查詢數據庫時收到錯誤消息。我正在使用INFORMIX 3.31 32位驅動程序(版本3.31.00.10287)。使用Informix驅動程序在R中使用ODBC連接時的SQL查詢錯誤
channel <- odbcConnect("exampleDSN")
unclass(channel)
[1] 3
attr(,"connection.string")
[1] "DSN=exampleDSN;UID=user;PWD=****;DB=exampleDB;HOST=exampleHOST;SRVR=exampleSRVR;SERV=exampleSERV;PRO=onsoctcp ... (more parameters)"
attr(,"handle_ptr")
<pointer: 0x0264c098>
attr(,"case")
[1] "nochange"
attr(,"id")
[1] 4182
attr(,"believeNRows")
[1] TRUE
attr(,"colQuote")
[1] "\""
attr(,"tabQuote")
[1] "\""
attr(,"interpretDot")
[1] TRUE
attr(,"encoding")
[1] ""
attr(,"rows_at_time")
[1] 100
attr(,"isMySQL")
[1] FALSE
attr(,"call")
odbcDriverConnect(connection = "DSN=exampleDSN")
當我嘗試查詢和調查返回的對象的結構時,收到錯誤訊息「CHR [1:2]「42000 -201 [Informix的] [Informix ODBC驅動程序] [Informix的一種語法錯誤已經發生。「 ...'
具體來說,我寫了一個表達式來遍歷數據庫中的所有表,檢索10行,並調查返回對象的結構。
for (i in 1:153){res <- sqlFetch(channel, sqlTables(channel, tableType="TABLE")$TABLE_NAME[i], max=10); str(res)}
每次迭代都會返回相同的錯誤消息。任何想法從哪裏開始?
附加信息:當我返回對象「水庫」,我收到以下 -
> res
[1] "42000 -201 [Informix][Informix ODBC Driver][Informix]A syntax error has occurred."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM \"exampleTABLE\"'"
當你查詢單個表時會發生什麼? – Chase 2011-05-18 20:13:48
@Chase:不管表是什麼,當我查詢單個表(並將查詢結果分配給'res')時,我收到與上面相同的錯誤消息(除了'exampleTABLE'是表的實際名稱)。 – Jubbles 2011-05-18 20:27:14
嗯...你有沒有嘗試過任何其他功能來檢索結果?也許'sqlQuery(通道,「從exampleTABLE選擇前10 *)'? – Chase 2011-05-18 20:40:09