使用c#从DBMS_OUTPUT.GET_LINES()获取输出
发布时间:2020-12-15 22:04:03 所属栏目:百科 来源:网络整理
导读:我知道如何从DBMS_OUTPUT.GET_LINE()获取输出. 你可以参考http://oradim.blogspot.com.tr/2007/05/odpnet-tip-retrieving-dbmsoutput-text.html 在此页面上,使用ODP.Net也可以解释输出表单DBMS_OUTPUT.GET_LINES()方法.有没有办法只使用ADO.NET来管理它. 例
我知道如何从DBMS_OUTPUT.GET_LINE()获取输出.
你可以参考http://oradim.blogspot.com.tr/2007/05/odpnet-tip-retrieving-dbmsoutput-text.html 在此页面上,使用ODP.Net也可以解释输出表单DBMS_OUTPUT.GET_LINES()方法.有没有办法只使用ADO.NET来管理它. 例如,如何从下面读取所有输出 begin declare stage number := 0; begin DBMS_OUTPUT.PUT_LINE('STARTING:'); INSERT INTO Country ( code,name) VALUES (1,'xxxx'); INSERT INTO City ( code,'yyyy'); DBMS_OUTPUT.PUT_LINE('DONE:'); COMMIT; EXCEPTION -- exception handlers begin WHEN OTHERS THEN -- handles all other errors DBMS_OUTPUT.PUT_LINE('Error occured,rollback...'); DBMS_OUTPUT.get_LINE(:1,:2); stage := -1; ROLLBACK; end; end; 输出应该是这样的: STARTING DONE 我有这个代码块,但它只返回第一个输出行 using (OracleCommand cmd = cnn.CreateCommand()) { OracleParameter status = new OracleParameter(":1",OracleType.VarChar,32000); p_line.Direction = ParameterDirection.Output; OracleParameter line = new OracleParameter(":2",OracleType.Double); p_status.Direction = ParameterDirection.Output; cmd.CommandText = script; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(status); cmd.Parameters.Add(line ); cmd.ExecuteNonQuery(); string status = status.Value.ToString(); string line = line.Value.ToString(); } 输出: STARTING 解决方法
DBMS_OUTPUT.GET_LINE仅返回缓冲区的第一行(并将其删除).如果使用此方法,则需要为每行调用一次.如果没有可用的行,则返回的状态为1.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |