SQLServer相比Oracle是很随便的,存储过程里select * from tb 就能返回一个结果集出来。在C#里调用时,能exec proc直接出结果集。
--SQL中返回结果集的存储过程:
create proc retable(@i int)
as
begin
select * from a where id=@i
end
GO
//C#里调用存储过程返回结果集的一种简便方法:
String sql = "exec retable "+textBox1.Text;
如果C#里调用SQLServer其他存储过程,那格式和下面ORACLE差不多。
Oracle里返回结果集需要用到out sys_refcursor游标,用存储过程和包都可以。
--Oracle中返回结果集的存储过程:
create or replace procedure outputtable(i_n int,emp out sys_refcursor)
as
begin
open emp for
select * from testa where a=i_n;
end outputtable;
想查看结果的话也比较麻烦,需要在pl-sql中先test这个存储过程,填入参数,F8运行,然后去output的value右下角点...这个东西。
(还有一种输出的方法是在command window中运行,和sqlplus类似,得用dbms_output.put_line('hell world)或者print 变量,但是command window对游标的支持貌似有问题,无法定义?)
&n