dbNextResult-methods(RMySQL)
dbNextResult-methods()所属R语言包:RMySQL
Fetch Next Result Set from Multiple Statements or Stored Procedures
从多个语句或存储过程中获取下一个结果集
译者:生物统计家园网 机器人LoveR
描述----------Description----------
dbMoreResults checks whether there are additional result sets for processing. dbNextResult fetches the next result set.
dbMoreResults检查是否有额外的结果集进行处理。 dbNextResult获取下一个结果集。
方法----------Methods----------
These MySQL methods provide functionality to sequentially extract multiple results produced by SQL scripts or stored procedures.
这些MySQL的方法提供了功能,顺序提取多个SQL脚本或存储过程产生的结果。
In the case of stored procedures invoked with CALL, the first result set indicates the call status, and output data (if any) are return as additional result sets.
与CALL调用的存储过程的情况下,第一个结果集显示通话状态,并输出数据(如果有的话)作为额外的结果集返回。
con = "MySQLConnection" a MySQL connection object.
CON =“的MySqlConnection”MySQL连接对象。
注意----------Note----------
MySQL supports SQL scripts (a single string with multiple statements terminated by ';') from version 4.1.1 onwards and stored procedures from version 5.0.
MySQL支持的SQL脚本(一个单独的字符串与多个语句的终止;)从版本4.1.1开始,从5.0版的存储过程。
To process SQL scripts on a MySQL connection, the connection must be created using the CLIENT\_MULTI\_STATEMENTS. In addition, to process stored procedures that return one or more result sets, the connection must be created using the CLIENT\_MULTI\_RESULTS client flag.
要处理一个MySQL连接的SQL脚本,连接必须创建使用的CLIENT\_MULTI\_STATEMENTS。此外,处理,返回一个或多个结果集的存储过程,必须建立连接使用CLIENT\_MULTI\_RESULTS客户端标志。
For simplicity, use CLIENT\_MULTI\_STATEMENTS for working with either SQL scripts or stored procedures. For more details, read on.
为了简单起见,使用CLIENT\_MULTI\_STATEMENTS使用SQL脚本或存储过程。有关详细信息,请阅读。
More precisely, to execute multiple statements the connection needs CLIENT\_MULTI\_STATEMENTS; this in turn automatically enables CLIENT\_MULTI\_RESULTS for fetching of multiple output results. On the other hand, the client flag CLIENT\_MULTI\_RESULTS by itself enables stored procedures to return one or more results. See the MySQL documentation in www.mysql.com for full details.
更确切地说,执行多个语句的连接需要CLIENT\_MULTI\_STATEMENTS,这反过来会自动启用CLIENT\_MULTI\_RESULTS多输出结果的获取。另一方面,在客户端标志CLIENT\_MULTI\_RESULTS本身使存储过程返回一个或多个结果。在www.mysql.com的全部详细信息,请参阅MySQL文档。
参见----------See Also----------
MySQL, dbConnect, dbSendQuery, dbHasCompleted, fetch, dbCommit, dbGetInfo, dbReadTable.
MySQL,dbConnect,dbSendQuery,dbHasCompleted,fetch,dbCommit,dbGetInfo,dbReadTable。
实例----------Examples----------
con <- dbConnect(MySQL(),
dbname = "rs-dbi",
client.flag=CLIENT\_MULTI\_STATEMENTS)
sql.script <- paste(
"select * from abc",
"select * def",
collapse = ";")
rs1 <- dbSendQuery(con, sql.script)
data1 <- fetch(rs1, n = -1)
if(dbMoreResults(con)){
rs2 <- dbNextResult(con)
## you could use dbHasCompleted(rs2) to determine whether[#你可以使用dbHasCompleted(RS2),以确定是否]
## rs2 is a select-like that generates output or not.[RS2是选择类似的或不产生输出。]
data2 <- fetch(rs2, n = -1)
}
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|