如何在oracle中将存储过程中的值返回到表 [英] how to return values from stored procedure to table in oracle
本文介绍了如何在oracle中将存储过程中的值返回到表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个过程,该过程对从表中获取的值进行排序,并显示正确的结果。但是如何获取结果并将其显示在表格中。
任何人都可以告诉我如何从程序中返回表中的结果?
I have created a procedure which is sorting the values that have been taken from the table, and it is displaying the correct result. but how to take that result and display it in the table.
Can any one please tell me how to return the result in the table from procedure?
推荐答案
在代码中添加一个游标put param
cmd.parameter.add(outcursor,Oracletype.cursor).direction = Parameterdirection.output;
datatable dt = cmd。 ExecuteReqader();
SP
---
声明/ /
outcursor sys_refcursor
开始
开启前瞻性
select * from .......
//你的桌子选择qry
end;
add a cursor out put param in code
cmd.parameter.add("outcursor",Oracletype.cursor).direction=Parameterdirection.output;
datatable dt=cmd.ExecuteReqader();
SP
---
declare//
outcursor sys_refcursor
begin
open outcursor for
select * from.............
// your table select qry
end;
创建或替换程序SP_sample
(
STROUT OUT SYS_REFCURSOR)
AS
BEGIN
OPEN STROUT FOR
SELECT * from tabletest;
END;
/
in c#code
cmd.CommandText =SP_sample
cmd.Com mandType = CommandType.StoredProcedure;
cmd.Parameters.Add(" STROUT",OracleType.Cursor).Direction = ParameterDirection.Output;
dt = DAOCLASS.ExecuteReader(cmd);
CREATE OR REPLACE PROCEDURE SP_sample
(
STROUT OUT SYS_REFCURSOR)
AS
BEGIN
OPEN STROUT FOR
SELECT * from tabletest;
END;
/
in c# code
cmd.CommandText = "SP_sample"
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("STROUT", OracleType.Cursor).Direction = ParameterDirection.Output;
dt = DAOCLASS.ExecuteReader(cmd);
这篇关于如何在oracle中将存储过程中的值返回到表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文