0

I have two tables product and condition where product_id is primary key of product and its foreign key in condition.

product
product_id name
1          eggs
2          milk

condition
product_id condition_name
1            new
2            bad
1            normal

I need a procedure which can give me the name of the all product which is not have bad condition.

DESLilly
  • 3
  • 5

1 Answers1

0

You can simply use single query as follows:

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');
Popeye
  • 35,427
  • 4
  • 10
  • 31
  • no, sorry i dont need query, i know the query, but i need a procedure – DESLilly Jun 05 '20 at 06:57
  • Use this query in the procedure. Then your procedure will be ready. – Popeye Jun 05 '20 at 06:59
  • i am trying it / – DESLilly Jun 05 '20 at 07:12
  • A stored procedure cannot return values with RETURN keyword (but a stored function can). A stored procedure can only return values in OUT parameter. How do you plan to use the stored procedure OUT parameter ? Please give details about host language and API. See PL/SQL examples in https://stackoverflow.com/questions/101033/how-to-return-multiple-rows-from-the-stored-procedure-oracle-pl-sql. – pifor Jun 05 '20 at 07:24