home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a524 / 37.ddi / demo / examp1.sql < prev    next >
Encoding:
Text File  |  1991-03-04  |  932 b   |  33 lines

  1. rem 
  2. rem $Header: examp1.sql,v 1002100.2 90/01/11 16:53:12 nsalah Exp $ examp1.sql Copyr (c) 1989 Oracle
  3. rem 
  4. rem V6PLS10021,DISK$DEV9:[PLS.DEMO.10021]
  5. /*
  6. ** This block processes an order for tennis racquets.  It will only
  7. ** decrement the number of tennis racquets in stock if there is
  8. ** at least one racquet left in stock.
  9. **
  10. ** Copyright (c) 1989 by Oracle Corporation
  11. */
  12.  
  13. DECLARE
  14.     num_in_stock    NUMBER(5);
  15. BEGIN
  16.     SELECT quantity INTO num_in_stock FROM inventory_table
  17.         WHERE product = 'TENNIS RACQUET';
  18.  
  19.         -- make sure there's enough in stock
  20.     IF num_in_stock > 0 THEN
  21.         UPDATE inventory_table SET quantity = quantity - 1
  22.             WHERE product = 'TENNIS RACQUET';
  23.         INSERT INTO purchase_record
  24.             VALUES ('TENNIS RACQUET PURCHASED.', SYSDATE);
  25.     ELSE
  26.         INSERT INTO purchase_record
  27.             VALUES ('OUT OF TENNIS RACQUETS.', SYSDATE);
  28.     END IF;
  29.  
  30.     COMMIT;
  31. END;
  32. /
  33.