Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE PROCEDURE createVenue(
- name IN VENUES.venue_name%type,
- lat IN VARCHAR,
- lon IN VARCHAR,
- capacity IN INTEGER,
- vtype IN VENUES.venue_type%type
- )IS
- BEGIN
- IF(validate_type_and_capacity(capacity, vtype)) THEN
- INSERT INTO VENUES VALUES (name, coordinates(lat, lon), capacity, vtype, 'active');
- dbms_output.put_line('NICE');
- END IF;
- EXCEPTION
- when data_error then
- dbms_output.put_line('error');
- END;
- /
- drop function "IT21324"."VALIDATE_TYPE_AND_CAPACITY";
- CREATE OR REPLACE FUNCTION validate_type_and_capacity(
- cap IN VENUES.capacity%type,
- type_param IN VENUES.venue_type%type
- ) RETURN boolean
- IS
- BEGIN
- if( (cap > 100 and cap < 1000 and type_param = 'square') OR
- (cap > 50 and cap < 500 and type_param = 'theater') OR
- (cap > 1000 and cap < 20000 and type_param = 'field')
- ) then
- return true;
- else
- return false;
- end if;
- END;
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement