fork download
  1.  
  2. CREATE OR REPLACE PROCEDURE avail_reduction_in_booking(
  3. reservation_id IN INT,
  4. reduction_percent IN NUMBER
  5. )
  6. AS
  7. v_original_price Halls.price%TYPE;
  8. v_reduced_price Halls.price%TYPE;
  9. BEGIN
  10. -- Retrieve the original price of the hall
  11. SELECT price
  12. INTO v_original_price
  13. FROM Halls
  14. WHERE hall_id = (
  15. SELECT hall_id
  16. FROM Reservations
  17. WHERE reservation_id = reservation_id
  18. );
  19.  
  20. -- Calculate the reduced price
  21. v_reduced_price := v_original_price - (v_original_price * reduction_percent / 100);
  22.  
  23. -- Update the booking price of the hall
  24. UPDATE Halls
  25. SET price = v_reduced_price
  26. WHERE hall_id = (
  27. SELECT hall_id
  28. FROM Reservations
  29. WHERE reservation_id = reservation_id
  30. );
  31.  
  32. -- Display the original and reduced prices
  33. DBMS_OUTPUT.PUT_LINE('Original Price: $' || v_original_price);
  34. DBMS_OUTPUT.PUT_LINE('Reduced Price: $' || v_reduced_price);
  35. END;
  36. /
  37.  
  38. BEGIN
  39. avail_reduction_in_booking(1, 10); -- Example usage: Apply 10% reduction for reservation ID 1
  40. END;
  41. /
  42.  
  43. SET SERVEROUTPUT ON
Success #stdin #stdout #stderr 0.01s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 2: near "OR": syntax error
Error: near line 8: near "v_reduced_price": syntax error
Error: near line 9: near "SELECT": syntax error
Error: near line 21: near "v_reduced_price": syntax error
Error: near line 24: no such table: Halls
Error: near line 33: near "DBMS_OUTPUT": syntax error
Error: near line 34: near "DBMS_OUTPUT": syntax error
Error: near line 35: cannot commit - no transaction is active
Error: near line 38: near "avail_reduction_in_booking": syntax error
Error: near line 40: cannot commit - no transaction is active
Error: near line 43: near "SET": syntax error