Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create trigger based two table before insert and check the balance from another table

user222Dec 1 2019 — edited Dec 27 2019

Hi MY Dear

I have two two table master detail in one page

  1. CREATE TABLE order_master 
  2.    order_id     NUMBER, 
  3.    order_kind   NUMBER, 
  4.    from_store_id number, 
  5.    to_store_id number, 
  6.    order_date   DATE 
  7. ); 
  8.  
  9.  
  10.  
  11.  
  12. CREATE TABLE order_detail 
  13.    ord_detail_id   NUMBER, 
  14.    order_id        NUMBER, 
  15.    item_code       NUMBER, 
  16.    qty             NUMBER 
  17. ); 

scenario is

customer create order with detail at same time

I need to create trigger at two table  check  in the  master table order_master  if  order_kind =1 " it means Deducted from inventory"   take the qty in order detail  and  check the value from this table

  1. create table inventory ( 
  2. inv_id number, 
  3. store_id number, 
  4. balance number); 

if  order_kind =1 and qty in order_datail  > the balance in inventory then refuese the operation

I cant create trigger at two table and check before insert

thanks in advance

Comments
Post Details
Added on Dec 1 2019
5 comments
4,299 views