title: Oracle PL/SQL How to rollback the newly inserted row
body: <pre><code>create or replace trigger trig_redeem_coffee
  before insert
  on buycoffee
  for each row
  declare
  CID int;
  customerPoint float;
  pointNeeded float;
  begin
      select customer_id into CID
      from purchase
      where purchase_id = :new.purchase_id;
      select total_points into customerPoint
      from customer
      where customer_id = CID;
      pro_get_redeem_point (:new.coffee_ID, :new.redeem_quantity, pointNeeded);
      if pointNeeded&gt;customerPoint
      then
          rollback;
      else
          pointNeeded := -1*pointNeeded;
          pro_update_point(CID, pointNeeded);
          end if;
      commit;
  end;
  /
  </code></pre>
  
  <p>The trigger can be successfully created, but when I insert into buycoffee table(it will meet the condition that pointNeeded>customerPoint), it returns an error that it cannot rollback in a trigger. Is this a proper way to rollback a newly inserted row? Or is there any better way to do it. (all procedures are built properly)</p>