参数值的数组Arrays of Parameter Values

它通常可用于应用程序传递参数数组。It is often useful for applications to pass arrays of parameters. 例如,使用参数数组和参数化 INSERT 语句,应用程序可以一次插入多个行。For example, using arrays of parameters and a parameterized INSERT statement, an application can insert a number of rows at once. 使用数组有几个优点。There are several advantages to using arrays. 首先,降低网络流量,因为如果数据源) 本身支持参数数组,则会在单个数据包 (中发送多个语句的数据。First, network traffic is reduced because the data for many statements is sent in a single packet (if the data source supports parameter arrays natively). 其次,某些数据源可以比执行相同数目的不同 SQL 语句,使用数组更快地执行 SQL 语句。Second, some data sources can execute SQL statements using arrays faster than executing the same number of separate SQL statements. 最后,当数据存储在数组中时,通常是屏幕数据的情况,应用程序可以将特定列中的所有行绑定到 SQLBindParameter ,并通过执行单个语句来更新这些行。Finally, when the data is stored in an array, as is often the case for screen data, the application can bind all of the rows in a particular column with a single call to SQLBindParameter and update them by executing a single statement.

遗憾的是,不是许多数据源支持参数数组。Unfortunately, not many data sources support parameter arrays. 但是,驱动程序可以通过对每组参数值执行一次 SQL 语句来模拟参数数组。However, a driver can emulate parameter arrays by executing an SQL statement once for each set of parameter values. 这可能会导致速度提高,因为驱动程序随后可以准备它计划为每个参数集执行一次的语句。This can lead to increases in speed because the driver can then prepare the statement that it plans to execute once for each parameter set. 它还可能导致应用程序代码更简单。It might also lead to simpler application code.

本部分包含以下主题。This section contains the following topics.