Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE createVenue(
  2. name IN VENUES.venue_name%type,
  3. lat IN VARCHAR,
  4. lon IN VARCHAR,
  5. capacity IN INTEGER,
  6. vtype IN VENUES.venue_type%type
  7. )IS
  8. BEGIN
  9. IF(validate_type_and_capacity(capacity, vtype)) THEN
  10. INSERT INTO VENUES VALUES (name, coordinates(lat, lon), capacity, vtype, 'active');
  11. dbms_output.put_line('NICE');
  12. END IF;
  13. EXCEPTION
  14. when data_error then
  15. dbms_output.put_line('error');
  16. END;
  17. /
  18. drop function "IT21324"."VALIDATE_TYPE_AND_CAPACITY";
  19. CREATE OR REPLACE FUNCTION validate_type_and_capacity(
  20. cap IN VENUES.capacity%type,
  21. type_param IN VENUES.venue_type%type
  22. ) RETURN boolean
  23. IS
  24. BEGIN
  25. if( (cap > 100 and cap < 1000 and type_param = 'square') OR
  26. (cap > 50 and cap < 500 and type_param = 'theater') OR
  27. (cap > 1000 and cap < 20000 and type_param = 'field')
  28. ) then
  29. return true;
  30. else
  31. return false;
  32. end if;
  33. END;
  34. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement