我爱Aspx >> C#.Net >> .NET调用Oracle存储过程,使用数组类型的参数(如ArrayList) _数据库技巧
今天一个项目组的朋友问及:如何在.NET中调用Oracle的存储过程,并以数组作为参数输入。
Oracle的PL/SQL非常强大,支持定长数组和变长数组,支持任何自定义数据类型。通过阅读ODP的文档,发现Oracle是完全支持将数组作为存储过程参数的。下面给出文档信息。
Array Binding
The array bind feature enables applications to bind arrays of a type using the OracleParameter class. Using the array bind feature, an application can insert multiple rows into a table in a single database round-trip.
The following example inserts three rows into the Dept table with a single database round-trip. The OracleCommand ArrayBindCount property defines the number of elements of the array to use when executing the statement.
// C#
using System;
using System.Data;
using Oracle.DataAccess.Client;
class ArrayBindSample
{
static void Main()
{
OracleConnection con = new OracleConnection();
con.ConnectionString = "User Id=scott;Password=tiger;Data Source=oracle;";
con.Open();
Console.WriteLine("Connected successfully");
int[] myArrayDeptNo = new int[3] { 10, 20, 30 };
OracleCommand cmd = new OracleCommand();
// Set the command text on an OracleCommand object
cmd.CommandText = "insert into dept(deptno) values (:deptno)";
cmd.Connection = con;
// Set the ArrayBindCount to indicate the number of values
cmd.ArrayBindCount = 3;
// Create a parameter for the array operations
OracleParameter prm = new OracleParameter("deptno", OracleDbType.Int32);
Ҷƪл˵?
oracle 存储过程的基本语法_数据..[04-28]
SQL Server 存储过程嵌套示例_数..[04-28]
SQL Server通用分页存储过程:利..[04-28]
防范SQL注入式攻击_数据库安全[04-28]
安全入门:SQL注入漏洞全接触_数据..[04-28]
ASP.NET中如何防范SQL注入式攻击..[04-28]
SQL注入奇招致胜 UNION查询轻松免..[04-28]
MSSQL db_owner角色注入直接获得..[04-28]
ASP.NET中如何防范SQL注入式攻击..[04-28]
SQL注入不完全思路与防注入程序_..[04-28]
oracle 存储过程的基本语法_数据..[04-28]
SQL Server 存储过程嵌套示例_数..[04-28]
SQL Server通用分页存储过程:利..[04-28]
防范SQL注入式攻击_数据库安全[04-28]
安全入门:SQL注入漏洞全接触_数据..[04-28]
ASP.NET中如何防范SQL注入式攻击..[04-28]
SQL注入奇招致胜 UNION查询轻松免..[04-28]
MSSQL db_owner角色注入直接获得..[04-28]
ASP.NET中如何防范SQL注入式攻击..[04-28]
SQL注入不完全思路与防注入程序_..[04-28]