Guest User

Untitled

a guest
Jun 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. create or replace procedure Buy_share(acno share_trans.account_no%type,
  2. shid share_trans.share_id%type,qty share_trans.quantity%type)is
  3.  
  4.  
  5.  
  6.  
  7. cursor cc1 is select share_idfrom share_trans,share_info where share_trans.account_no=share_info.account_no and share_id= shid and quantity=qtyfor update of qty nowait;
  8. tno share_trans.transaction_no%type;
  9. ttype share_trans.trans_type%type;
  10. tdate share_trans.trans_date%type;
  11.  
  12.  
  13. begin
  14. unit:=Enquiry(acno,shid);
  15.  
  16. shid:=&shid;
  17.  
  18. qty:=&qty;
  19.  
  20.  
  21. for cc1_rec in cc1 loop
  22.  
  23. if shid>0 then
  24.  
  25. update share_trans set qty=qty+unit where current of cc1;
  26.  
  27. commit;
  28.  
  29. dbms_output.put_line('found/update');
  30.  
  31. else
  32.  
  33. insert into share_info values(acno,shid,unit);
  34.  
  35. end if;
  36.  
  37. insert into share_trans values(acno,tno,shid,qty,ttype,tdate);
  38.  
  39. end loop;
  40.  
  41. end;
Add Comment
Please, Sign In to add comment