0
SQL> create table master(pno number(5) primary key,pname varchar2(20),price number(10,2),stock
number(5));
Table created.
SQL> create table trans(p_no number(5),no_pro_sold number(5));
Table created.
SQL> insert into master values(&product_no,'&product_name',&price,&stock_in_hand);
Enter value for product_no: 1
Enter value for product_name: cd
Enter value for price: 700
Enter value for stock_in_hand: 6
old 1: insert into master values(&product_no,'&product_name',&price,&stock_in_hand)
new 1: insert into master values(1,'cd',700,6)
1 row created.
SQL> /
Enter value for product_no: 2
Enter value for product_name: dvd
Enter value for price: 600
Enter value for stock_in_hand: 9
old 1: insert into master values(&product_no,'&product_name',&price,&stock_in_hand)
new 1: insert into master values(2,'dvd',600,9)
SQL> /
Enter value for product_no: 3
Enter value for product_name: vcd
Enter value for price: 600
Enter value for stock_in_hand: 7
old 1: insert into master values(&product_no,'&product_name',&price,&stock_in_hand)
new 1: insert into master values(3,'vcd',600,7)
1 row created.
SQL> select * from master8;
PNO PNAME PRICE STOCK
---------- -------------------- ---------- ----------
 1 cd 700 6
 2 dvd 600 9
 3 vcd 600 7
SQL> create or replace trigger t1 after insert or update on trans for each row
  2  declare
  3  cursor c1 is select * from master where pno=:new p_no;
  4  begin
  5  for i in c1 loop
  6  if i.stock<:new.no_pro_sold then
  7  raise_application_error(-20001,'no.of product more than stock,error');
  8  end if;
  9  end loop;
 10  end;
 11  /

Warning: Trigger created with compilation errors. ```

How do I solve this problem
0

1 Answer 1

2

Knowing how to debug your own code is important.

Try running show errors in SQLPlus.

It should tell you that something is wrong with line 3.

The rest is easy to fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.