R dbplyr SQL 错误 "expecting something between Database_Name and LIMIT"
R dbplyr SQL Error "expecting something between Database_Name and LIMIT"
这是我们正在使用的连接:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "[your driver's name]",
Host = "[your server's path]",
DBCName = "[IP Address or Alias]"
UID = rstudioapi::askForPassword("Database user"),
PWD = rstudioapi::askForPassword("Database password"))
下面的命令在我的代码中运行良好,没有错误,并且输出看起来是正确的:
table1 <- tbl(con, "SAP_PRD_QMEL_ACQ")
但是,当我 运行 这行代码时,出现以下错误:
table2 <- DBI::dbGetQuery(con, "SELECT * FROM SAP_PRD_QMEL_ACQ LIMIT 5")
#> Error in new_result(connection@ptr, statement) :
#> nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]
#> [Teradata Database](-3706)Syntax error: expected something between the word
#> 'SAP_PRD_QMEL_ACQ' and the 'LIMIT' keyword.
当我创建简单的重现来尝试复制错误时,我空手而归。为什么我会收到此 "expecting something between Database_Name and LIMIT" 错误?
无法重现您的问题,但我相信您需要使用 TOP
而不是 LIMIT
:
table2 <- DBI::dbGetQuery(con, "SELECT TOP 5 * FROM SAP_PRD_QMEL_ACQ")
这是我们正在使用的连接:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "[your driver's name]",
Host = "[your server's path]",
DBCName = "[IP Address or Alias]"
UID = rstudioapi::askForPassword("Database user"),
PWD = rstudioapi::askForPassword("Database password"))
下面的命令在我的代码中运行良好,没有错误,并且输出看起来是正确的:
table1 <- tbl(con, "SAP_PRD_QMEL_ACQ")
但是,当我 运行 这行代码时,出现以下错误:
table2 <- DBI::dbGetQuery(con, "SELECT * FROM SAP_PRD_QMEL_ACQ LIMIT 5")
#> Error in new_result(connection@ptr, statement) :
#> nanodbc/nanodbc.cpp:1344: 42000: [Teradata][ODBC Teradata Driver]
#> [Teradata Database](-3706)Syntax error: expected something between the word
#> 'SAP_PRD_QMEL_ACQ' and the 'LIMIT' keyword.
当我创建简单的重现来尝试复制错误时,我空手而归。为什么我会收到此 "expecting something between Database_Name and LIMIT" 错误?
无法重现您的问题,但我相信您需要使用 TOP
而不是 LIMIT
:
table2 <- DBI::dbGetQuery(con, "SELECT TOP 5 * FROM SAP_PRD_QMEL_ACQ")