Oracle 过程中的 Select 语句
很抱歉问这个问题,但这是因为之前给出的答案都不足以让我理解。我想编写一个返回表中所有列的存储过程。作为一个临时查询,我只是编写
SELECT * FROM EMPLOYEES
但在这里,我收到一个错误,提示我提供 INTO
子句,但我没有提供理解为什么以及如何。有人可以解释一下在上述情况下以及当我只想返回一列值(多行)时我将如何执行此操作。
sorry for asking this question but it's because none of the answers given before are enough for me to understand. I want to write a stored procedure that returns all the columns in a table.As an ad hod query I just write
SELECT * FROM EMPLOYEES
but here, I get an error which prompts me to provide INTO
clause which I don't understand why and how.Could someone explain how would I do that both in the above case and when I want to return just one column values(multiple rows).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
具有 SQL Server 背景的人习惯于编写返回整个查询结果的存储过程,因此尝试编写如下所示的 PL/SQL 过程:
不幸的是,它并不那么简单。 PL/SQL 中最接近的等价物可能是返回引用游标的函数:
您可以从调用程序中调用它,如下所示:
或者在 SQL Plus 中您可以执行以下操作:
People with a SQL Server background are used to writing stored procedures that return whole query results and so try to write PL/SQL procedures something like this:
Unfortunately it's not that simple. Probably the nearest equivalent in PL/SQL is a function returning a ref cursor:
You could call this from a calling program like this:
or in SQL Plus you could do: