从 C# 调用 oracle 函数

发布于 2024-08-02 21:01:31 字数 360 浏览 4 评论 0原文

我有一个 Oracle 函数 GetEmployeeDetails,它将所有员工详细信息保存到临时表 TempEmployeeDetails 表中。

我必须调用该函数,然后对临时表进行选择查询。函数调用成功,但选择查询抛出以下错误。

“开始:输出:= MyPackage.GetEmployeeDetails(” +“:员工ID,”);从 TempEmployeeDetails 中选择 *; END;"

上面的查询给了我这个错误:

ORA-06550: line 1, column 98:

PLS-00428: an INTO Clause is Expected in this SELECT statements

I have an Oracle function GetEmployeeDetails which saves all the employee details into a temporary table TempEmployeeDetails table.

I have to call the function followed by a select query on the temporary table. The function call succeeds but the select query throws the following error.

"BEGIN :Output := MyPackage.GetEmployeeDetails("
+ ":EmployeeId,"); SELECT * FROM TempEmployeeDetails; END;"

The above query is giving me this error:

ORA-06550: line 1, column 98:

PLS-00428: an INTO clause is expected in this SELECT statement

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩虹直至黑白 2024-08-09 21:01:31

我认为如果您使用的是 OracleClient,则应该将查询与函数调用分开,因此代码可能是:

OracleCommand cmd = new OracleCommand("GetEmployeeDetails", conn);
cmd.CommandType = CommandType.StoredProcedure;


par = new OracleParameter("EmployeeId", OracleType.int32);
par.Value = EmployeeId;
par.Direction = ParameterDirection.Input;
cmd.Parameters.Add(par);

cmd.ExecuteNonQuery();

现在要从 tempEmployeeDetails 获取数据,请进行另一个查询,如下所示:

OracleCommand cmd = new OracleCommand("SELECT * FROM TempEmployeeDetails", conn);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
   //do what you want...
}

I think you should separate the query from the function call, if you are using OracleClient so the code probably by:

OracleCommand cmd = new OracleCommand("GetEmployeeDetails", conn);
cmd.CommandType = CommandType.StoredProcedure;


par = new OracleParameter("EmployeeId", OracleType.int32);
par.Value = EmployeeId;
par.Direction = ParameterDirection.Input;
cmd.Parameters.Add(par);

cmd.ExecuteNonQuery();

now to get the data from tempEmployeeDetails make another query like the following:

OracleCommand cmd = new OracleCommand("SELECT * FROM TempEmployeeDetails", conn);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
   //do what you want...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文