本文介绍了如何在C#中调用oracle函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个oracle函数,它有3个参数并返回有4列的记录。 但是我得到的例外是 ORA-06550:第1行第7列: PLS-00221:'get_receipts'不是程序或未定义 这是我的代码。 cmd.CommandText =get_receipts; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new OracleParameter(p_store_num,store_num)); cmd.Parameters.Add(new OracleParameter(p_create_dt,create_date)); cmd.Parameters.Add(new OracleParameter(p_cc_last4,cc_last4)); } OracleDataReader dr = cmd.ExecuteReader(); while(dr.Read()) { ResponseModel sample = new ResponseModel(); sample.Field1 = dr.GetString(0); sample.Field2 = dr.GetString(1); sample.Field3 = dr.GetString(2); sample.Field4 = dr.GetString(3); response.Add(sample); } 我的尝试: 这是我的代码。 cmd.CommandText =get_receipts; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new OracleParameter(p_store_num,store_num)); cmd.Parameters.Add(new OracleParameter(p_create_dt,create_date)); cmd.Parameters.Add(new OracleParameter(p_cc_last4,cc_last4)); } OracleDataReader dr = cmd.ExecuteReader(); while(dr.Read()) { ResponseModel sample = new ResponseModel(); sample.Field1 = dr.GetString(0); sample.Field2 = dr.GetString(1); sample.Field3 = dr.GetString(2); sample.Field4 = dr.GetString(3); response.Add(sample); } 解决方案 问题是没有调用存储过程,问题是SQL drtbrt不知道你的存储过程打电话。 消息相当明确! 检查SQL服务器上存在哪些存储过程。 /> 和正确的程序名称或创建程序。 嘿伙计们谢谢你们。我问过创建函数的人来存储proc并在我的代码中进行了以下更改。请告诉我是否提供max int size是好的.. cmd.CommandText =get_receipts; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new OracleParameter(p_store_num,store_num)); cmd.Parameters.Add(new OracleParameter(p_create_dt,create_date)); cmd.Parameters.Add(new OracleParameter(p_cc_last4,cc_last4)); cmd.Parameters.Add(new OracleParameter(o_return_cur,OracleDbType.RefCursor, int.MaxValue ,ParameterDirection.Output)); I have an oracle function,which takes 3 parametes and return records which has four columns.But I am getting an exception which isORA-06550: line 1, column 7:PLS-00221: 'get_receipts' is not a procedure or is undefinedthis is my code.cmd.CommandText = "get_receipts"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new OracleParameter("p_store_num", store_num)); cmd.Parameters.Add(new OracleParameter("p_create_dt", create_date)); cmd.Parameters.Add(new OracleParameter("p_cc_last4", cc_last4)); } OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ResponseModel sample = new ResponseModel(); sample.Field1 = dr.GetString(0); sample.Field2 = dr.GetString(1); sample.Field3 = dr.GetString(2); sample.Field4 = dr.GetString(3); response.Add(sample); }What I have tried:this is my code.cmd.CommandText = "get_receipts"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new OracleParameter("p_store_num", store_num)); cmd.Parameters.Add(new OracleParameter("p_create_dt", create_date)); cmd.Parameters.Add(new OracleParameter("p_cc_last4", cc_last4)); } OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ResponseModel sample = new ResponseModel(); sample.Field1 = dr.GetString(0); sample.Field2 = dr.GetString(1); sample.Field3 = dr.GetString(2); sample.Field4 = dr.GetString(3); response.Add(sample); } 解决方案The problem is not calling a stored procedure, the problem is that SQL drtbrt don't know the stored procedure you are calling.Message is rather explicit!Check what stored procedure exist on SQL server.And correct procedure name or create procedure. 这篇关于如何在C#中调用oracle函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-18 20:37