使用ADO.NET访问Oracle 9i存储过程(上)
http://tech.ddvip.com 2007年05月13日 社区交流
本文详细介绍使用ADO.NET访问Oracle 9i存储过程(上)
以下 Oracle 存储过程删除了由单个输入参数指定的员工的所有工作经历,并且不返回任何数据。
CREATE OR new PROCEDURE DELETE_JOB_HISTORY
(
p_employee_id NUMBER
)
IS
BEGIN
DELETE FROM job_history
WHERE employee_id = p_employee_id;
END DELETE_JOB_HISTORY;以下代码运行了该存储过程。
// create the connection
OracleConnection conn = new OracleConnection("Data Source=oracledb;
User Id=UserID;Password=Password;");
// create the command for the stored procedure
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "COUNT_JOB_HISTORY";
cmd.CommandType = CommandType.StoredProcedure;
// add the parameter specifying the employee for whom to delete records
cmd.Parameters.Add("p_employee_id", OracleType.Number).Value = 102;
OracleString rowId;
// execute the stored procedure
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
Console.WriteLine("Rows affected: " + rowsAffected);如果您尚未修改默认的 HR 安装,则 JOB_HISTORY 表中员工 102 的记录被删除,并且向控制台输出以下内容:
Rows affected: 1
访问返回值
RETURN 语句立即将控制从存储过程返回到调用程序。Oracle 存储过程中的 RETURN 语句无法像在 T-SQL 中那样返回值。
责编:豆豆技术应用
正在加载评论...
- Oracle 10g 教程
- Oracle 故障处理
- Oracle 存储过程
- Oracle 备份恢复
- Oracle 性能调优
- Oracle 9i 教程
- Oracle 11g 教程
- Oracle 启动
- Oracle 命令
- Oracle 数据库管理
- Oracle 时间
- Oracle 密码
- Oracle 用户
- Oracle 常见错误
- Oracle 建数据表
- Oracle 索引
- Oracle 数据库连接
- Oracle 锁
- Oracle RAC 专题
- Oracle exp/imp 命令
- Oracle 表空间
- Oracle 查询
- Oracle 函数
- Oracle PL/SQL 专题
- 更多Oracle 专题>>>