此错误是什么意思?
Closing open result set, pending rowsError in result_create(conn@ptr, statement) : near "(": syntax error
当我想运行代码时出现
```{r}
library(sqldf)
first <- dbConnect(SQLite(), dbname= "DATA.sqlite")
dbSendQuery(conn = first,
"CREATE TABLE COMPANY_MASTER
(
CompId INTEGER,
CompName TEXT,
Address TEXT,
DirectorName TEXT,
EmployeeNo INTEGER,
PRIMARY KEY(CompName)
)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1001,'Infosys','ABC1927','Dr.Sandeep',128)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1002,'Cognizant','ERT654','Michael',156)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1003,'Tata','PCD531','Sancheti',113)")
*
dbSendQuery(conn = first,
"CREATE TABLE INCOME
(
CompName TEXT,
In(2016) INTEGER,
In(2017) INTEGER,
In(2018) INTEGER,
FOREIGN KEY(CompName)
*
)")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('518361','528464','538646')")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('218434','205314','225815')")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('1038434','1184344','128434')")
CompMAst <- dbGetQuery(conn = first, "SELECT * FROM COMPANY_MASTER")
Income <- dbGetQuery(conn = first, "SELECT * FROM INCOME")
```
在
中给出上述错误时dbSendQuery(conn = first,
"CREATE TABLE INCOME
(
CompName TEXT,
In(2016) INTEGER,
In(2017) INTEGER,
In(2018) INTEGER,
FOREIGN KEY(CompName)
)")
代码的区域。这个错误是什么意思?是否存在某些特定的格式错误?还是我错过了执行之前必须提到的一些块。还是涉及其他软件包,请帮助。
答案 0 :(得分:1)
根据@SatZ和您给出四列并输入三个值的错误,您的理想代码应该是
```{r}
library(sqldf)
first <- dbConnect(SQLite(), dbname= "DATA.sqlite")
dbSendQuery(conn = first,
"CREATE TABLE COMPANY_MASTER
(
CompId INTEGER,
CompName TEXT,
Address TEXT,
DirectorName TEXT,
EmployeeNo INTEGER,
PRIMARY KEY(CompName)
)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1001,'Infosys','ABC1927','Dr.Sandeep',128)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1002,'Cognizant','ERT654','Michael',156)")
dbSendQuery(conn = first, "INSERT INTO COMPANY_MASTER
VALUES(1003,'Tata','PCD531','Sancheti',113)")
dbSendQuery(conn = first,
"CREATE TABLE INCOME
(
CompName TEXT,
IN_2016 TEXT,
IN_2017 TEXT,
IN_2018 TEXT)")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('Infosys','5183.61','5284.64','5386.46')")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('Cognizant','2184.34','2053.14','2258.15')")
dbSendQuery(conn = first, "INSERT INTO INCOME
VALUES('Tata','10384.34','11843.44','1284.34')")
CompMAst <- dbGetQuery(conn = first, "SELECT * FROM COMPANY_MASTER")
Income <- dbGetQuery(conn = first, "SELECT * FROM INCOME")
```
答案 1 :(得分:0)
<form class="checkout">
<div class="col-1"></div>
<h3>Overview</h3>
<div class="col-2"></div>
</form>
方法返回一个dbSendQuery()
对象,使用"DBIResult"
清除它是调用者的责任。对于不返回结果集的查询,请使用dbClearResult()
而不是dbExecute()
以避免警告。 ({dbSendQuery()
与dbExecute()
等效,对于不返回结果集的查询。)
有关较长格式dbGetQuery()
+ dbBind()
+ dbSendQuery()
的用例,请参见dbFetch()
的帮助。