【问题标题】:can i use join in stored procedures - oracle database我可以在存储过程中使用联接吗 - oracle 数据库
【发布时间】:2020-09-24 04:36:29
【问题描述】:

我有两个表产品和条件,其中product_id 是产品的主键,它的外键是条件。

product
product_id name
1          eggs
2          milk

condition
product_id condition_name
1            new
2            bad
1            normal

我需要一个程序,它可以给我所有状况良好的产品的名称。

【问题讨论】:

  • 为什么需要存储过程?一个简单的查询就足够了。

标签: oracle stored-procedures


【解决方案1】:

您可以简单地使用单个查询,如下所示:

select p.name
  from product p
where not exists (select 1 from condition c where p.product_id = c.product_id
and c.condition_name = 'bad');

【讨论】:

  • 不,对不起,我不需要查询,我知道查询,但我需要一个程序
  • 在过程中使用此查询。然后你的程序就准备好了。
  • 我正在尝试/
  • 存储过程不能使用 RETURN 关键字返回值(但存储函数可以)。存储过程只能在 OUT 参数中返回值。您打算如何使用存储过程的 OUT 参数?请提供有关主机语言和 API 的详细信息。请参阅stackoverflow.com/questions/101033/… 中的 PL/SQL 示例。
猜你喜欢
  • 2011-07-20
  • 1970-01-01
  • 2011-02-28
  • 1970-01-01
  • 2019-01-21
  • 2011-03-05
  • 2023-04-02
  • 2013-01-31
  • 2020-04-03
相关资源
最近更新 更多