INSERT ALL
  INTO LOCATIONS VALUES(LOCATIONS_SEQ.NEXTVAL, odessa_city_id, 'Chaikovs''koho Ln', '1')
  INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Opera theatre', 5, 46.485435, 30.7403397, TO_DATE('20.10.2016', 'DD.MM.YYYY'), 1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id)
  INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, tag1_id)
  INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, tag2_id)  
  SELECT
    CITIES.ID AS odessa_city_id,
    CATEGORIES.ID AS category_id,
    TAG1.ID AS tag1_id,
    TAG2.ID AS tag2_id,
    USERS.id AS user_id
  FROM
    CITIES, CATEGORIES, TAGS TAG1, TAGS TAG2, USERS 
  WHERE
    CITIES.NAME = 'Odessa' AND CATEGORIES.NAME = 'Theaters' AND 
    TAG1.NAME = 'Opera' AND TAG2.NAME = 'Buildings' AND USERS.last_name = 'Ivanov';
	
INSERT ALL
  INTO LOCATIONS VALUES(LOCATIONS_SEQ.NEXTVAL, odessa_city_id, 'Potemkin Stairs', NULL)
  INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Potemkin Stairs', 5, 46.4888231, 30.7415912, TO_DATE('20.10.2015', 'DD.MM.YYYY'), 1)
  INTO TAGS VALUES(TAGS_SEQ.NEXTVAL, 'Stairs')
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id)
  INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, TAGS_SEQ.CURRVAL)
  SELECT
    CITIES.ID AS odessa_city_id,
    CATEGORIES.ID AS category_id,
    USERS.id AS user_id
  FROM
    CITIES, CATEGORIES, USERS
  WHERE
    CITIES.NAME = 'Odessa' AND CATEGORIES.NAME = 'Historical objects' AND USERS.last_name = 'Ivanov';

INSERT ALL
  INTO LOCATIONS VALUES(LOCATIONS_SEQ.NEXTVAL, odessa_city_id, 'Marazliivska St', '1')
  INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Central Stadium Chernomorets', 5, 46.4804128, 30.7565879, TO_DATE('10.10.2016', 'DD.MM.YYYY'), 1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id2)
  INTO TAGS VALUES(TAGS_SEQ.NEXTVAL, 'Stadium')
  INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, TAGS_SEQ.CURRVAL)
  INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, tag1_id)
  SELECT
    CITIES.ID AS odessa_city_id,
    CAT1.ID AS category_id1,
    CAT2.ID AS category_id2,
    TAGS.ID AS tag1_id,
    USERS.id AS user_id
  FROM
    CITIES, CATEGORIES CAT1, CATEGORIES CAT2, TAGS, USERS
  WHERE
    CITIES.NAME = 'Odessa' AND CAT1.NAME = 'Sport' AND
    CAT2.NAME = 'Entertainment' AND TAGS.NAME = 'Football' AND USERS.last_name = 'Ivanov';

INSERT ALL
  INTO LOCATIONS VALUES(LOCATIONS_SEQ.NEXTVAL, odessa_city_id, 'Plyazh Lanzheron', '25')
  INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Dolphinarium "Nemo"', 5, 46.4804128, 30.7565879, SYSDATE - 1, 1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id2)
  SELECT
    CITIES.ID AS odessa_city_id,
    CAT1.ID AS category_id1,
    CAT2.ID AS category_id2,
    USERS.id AS user_id
  FROM
    CITIES, CATEGORIES CAT1, CATEGORIES CAT2, USERS
  WHERE
    CITIES.NAME = 'Odessa' AND CAT1.NAME = 'Beaches' AND
    CAT2.NAME = 'Entertainment' AND USERS.last_name = 'Ivanov';

INSERT ALL
  INTO CITIES VALUES(CITIES_SEQ.NEXTVAL, state_id, 'Fontanka')
  INTO LOCATIONS VALUES (LOCATIONS_SEQ.NEXTVAL, CITIES_SEQ.CURRVAL, 'Pivdenna Rd', '101а')
  INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Riviera Shopping City', 5, 46.5628008, 30.8377934, SYSDATE - 1, 1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id1)
  INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, category_id2)
  SELECT
    STATES.ID AS state_id,
    CAT1.ID AS category_id1,
    CAT2.ID AS category_id2,
    USERS.id AS user_id
  FROM
    STATES, CATEGORIES CAT1, CATEGORIES CAT2, USERS
  WHERE
    STATES.NAME = 'Odessa Oblast' AND CAT1.NAME = 'Shops' AND CAT2.NAME = 'Cinema' AND USERS.last_name = 'Ivanov';



DECLARE
	city_id CITIES.ID%TYPE;
	catecory_id CATEGORIES.ID%TYPE;
	user_id USERS.ID%TYPE;
BEGIN

	SELECT
		ID
	INTO city_id
	FROM
		CITIES
	WHERE
		CITIES.NAME = 'Odessa';
		
	SELECT
		ID
	INTO catecory_id
	FROM
		CATEGORIES
	WHERE
		CATEGORIES.NAME = 'Other';
		
	SELECT
		ID
	INTO user_id
	FROM
		USERS
	WHERE
		LAST_NAME = 'Ivanov';
		
	FOR i IN 1..300 LOOP
		INSERT INTO LOCATIONS VALUES (LOCATIONS_SEQ.NEXTVAL, city_id, 'test', TO_CHAR(i));
		INSERT INTO LABELS VALUES(LABELS_SEQ.NEXTVAL, user_id, LOCATIONS_SEQ.CURRVAL, 'Test', 5, (46.513338 + i / 10000000), (30.733660 + i / 10000000), SYSDATE - i, 1);
		INSERT INTO CATEGORIES_LABELS VALUES(LABELS_SEQ.CURRVAL, catecory_id);
		INSERT INTO TAGS VALUES(TAGS_SEQ.NEXTVAL, 'Test' || i);
		INSERT INTO TAGS_LABELS VALUES(LABELS_SEQ.CURRVAL, TAGS_SEQ.CURRVAL);
	END LOOP;

END;
/	