--ZMAZANIE TABULKY ADRESAR03
--DROP TABLE ADRESAR03;
--VYTVORENIE TABULKY ADRESAR03
CREATE TABLE ADRESAR03(
IDADRESAR INT NOT NULL PRIMARY KEY,
NAME VARCHAR(50),
ADDRESS VARCHAR(80),
IDPRAVNAFORMA INT,
CREATE_DATE DATE,
INVALID_ADRESS VARCHAR(2),
IDKRAJ INT,
IDOKRES INT,
IDOBEC INT);
--ZMAZANIE TABULKY PRAVFORM
--DROP TABLE PRAVFORM;
--VYTVORENIE TABULKY PRAVFORM
CREATE TABLE PRAVFORM(
IDPRAVFORM INT NOT NULL PRIMARY KEY,
NAME VARCHAR(50)
);
INSERT INTO PRAVFORM
VALUES(1, 'Právnická osoba');
INSERT INTO PRAVFORM
VALUES(2, 'Fyzická osoba');
COMMIT;
--DROP TABLE CKRAJ;
CREATE TABLE CKRAJ
(
ID_KRAJ INT PRIMARY KEY,
NAZOV_KRAJ VARCHAR(50)
);
INSERT INTO CKRAJ
VALUES(1, 'Bratislavský');
INSERT INTO CKRAJ
VALUES(2, 'Trnavský');
INSERT INTO CKRAJ
VALUES(3, 'Trenčiansky');
INSERT INTO CKRAJ
VALUES(4, 'Nitriansky');
INSERT INTO CKRAJ
VALUES(5, 'Žilinský');
INSERT INTO CKRAJ
VALUES(6, 'Banskobystrický');
INSERT INTO CKRAJ
VALUES(7, 'Prešovský');
INSERT INTO CKRAJ
VALUES(8, 'Košický');
COMMIT;
--DROP TABLE COKRES;
CREATE TABLE COKRES
(
ID_OKRES INT PRIMARY KEY,
ID_KRAJ INT NOT NULL,
NAZOV_OKRES VARCHAR(50)
);
INSERT INTO COKRES VALUES(1, 1, 'Bratislava I');
INSERT INTO COKRES VALUES(2, 1, 'Bratislava II');
INSERT INTO COKRES VALUES(3, 1, 'Bratislava III');
INSERT INTO COKRES VALUES(4, 1, 'Bratislava IV');
INSERT INTO COKRES VALUES(5, 1, 'Bratislava V');
INSERT INTO COKRES VALUES(6, 1, 'Malacky');
INSERT INTO COKRES VALUES(7, 1, 'Pezinok');
INSERT INTO COKRES VALUES(8, 1, 'Senec');
INSERT INTO COKRES VALUES(9, 2, 'Dunajská Streda');
INSERT INTO COKRES VALUES(10, 2, 'Galanta');
INSERT INTO COKRES VALUES(11, 2, 'Hlohovec');
INSERT INTO COKRES VALUES(12, 2, 'Piešťany');
INSERT INTO COKRES VALUES(13, 2, 'Senica');
INSERT INTO COKRES VALUES(14, 2, 'Skalica');
INSERT INTO COKRES VALUES(15, 2, 'Trnava');
INSERT INTO COKRES VALUES(16, 3, 'Bánovce nad Bebravou');
INSERT INTO COKRES VALUES(17, 3, 'Ilava');
INSERT INTO COKRES VALUES(18, 3, 'Myjava');
INSERT INTO COKRES VALUES(19, 3, 'Nové Mesto nad Váhom');
INSERT INTO COKRES VALUES(20, 3, 'Partizánske');
INSERT INTO COKRES VALUES(21, 3, 'Považská Bystrica');
INSERT INTO COKRES VALUES(22, 3, 'Prievidza');
INSERT INTO COKRES VALUES(23, 3, 'Púchov');
INSERT INTO COKRES VALUES(24, 3, 'Trenčín');
INSERT INTO COKRES VALUES(25, 4, 'Komárno');
INSERT INTO COKRES VALUES(26, 4, 'Levice');
INSERT INTO COKRES VALUES(27, 4, 'Nitra');
INSERT INTO COKRES VALUES(28, 4, 'Nové Zámky');
INSERT INTO COKRES VALUES(29, 4, 'Šaľa');
INSERT INTO COKRES VALUES(30, 4, 'Topoľčany');
INSERT INTO COKRES VALUES(31, 4, 'Zlaté Moravce');
INSERT INTO COKRES VALUES(32, 5, 'Bytča');
INSERT INTO COKRES VALUES(33, 5, 'Čadca');
INSERT INTO COKRES VALUES(34, 5, 'Dolný Kubín');
INSERT INTO COKRES VALUES(35, 5, 'Kysucké Nové Mesto');
INSERT INTO COKRES VALUES(36, 5, 'Liptovský Mikuláš');
INSERT INTO COKRES VALUES(37, 5, 'Martin');
INSERT INTO COKRES VALUES(38, 5, 'Námestovo');
INSERT INTO COKRES VALUES(39, 5, 'Ružomberok');
INSERT INTO COKRES VALUES(40, 5, 'Turčianske Teplice');
INSERT INTO COKRES VALUES(41, 5, 'Tvrdošín');
INSERT INTO COKRES VALUES(42, 5, 'Žilina');
INSERT INTO COKRES VALUES(43, 6, 'Banská Bystrica');
INSERT INTO COKRES VALUES(44, 6, 'Banská Štiavnica');
INSERT INTO COKRES VALUES(45, 6, 'Brezno');
INSERT INTO COKRES VALUES(46, 6, 'Detva');
INSERT INTO COKRES VALUES(47, 6, 'Krupina');
INSERT INTO COKRES VALUES(48, 6, 'Lučenec');
INSERT INTO COKRES VALUES(49, 6, 'Poltár');
INSERT INTO COKRES VALUES(50, 6, 'Revúca');
INSERT INTO COKRES VALUES(51, 6, 'Rimavská Sobota');
INSERT INTO COKRES VALUES(52, 6, 'Veľký Krtíš');
INSERT INTO COKRES VALUES(53, 6, 'Zvolen');
INSERT INTO COKRES VALUES(54, 6, 'Žarnovica');
INSERT INTO COKRES VALUES(55, 6, 'Žiar nad Hronom');
INSERT INTO COKRES VALUES(56, 7, 'Bardejov');
INSERT INTO COKRES VALUES(57, 7, 'Humenné');
INSERT INTO COKRES VALUES(58, 7, 'Kežmarok');
INSERT INTO COKRES VALUES(59, 7, 'Levoča');
INSERT INTO COKRES VALUES(60, 7, 'Medzilaborce');
INSERT INTO COKRES VALUES(61, 7, 'Poprad');
INSERT INTO COKRES VALUES(62, 7, 'Prešov');
INSERT INTO COKRES VALUES(63, 7, 'Sabinov');
INSERT INTO COKRES VALUES(64, 7, 'Snina');
INSERT INTO COKRES VALUES(65, 7, 'Stará Ľubovňa');
INSERT INTO COKRES VALUES(66, 7, 'Stropkov');
INSERT INTO COKRES VALUES(67, 7, 'Svidník');
INSERT INTO COKRES VALUES(68, 7, 'Vranov nad Topľou');
INSERT INTO COKRES VALUES(69, 8, 'Gelnica');
INSERT INTO COKRES VALUES(70, 8, 'Košice I');
INSERT INTO COKRES VALUES(71, 8, 'Košice II');
INSERT INTO COKRES VALUES(72, 8, 'Košice III');
INSERT INTO COKRES VALUES(73, 8, 'Košice IV');
INSERT INTO COKRES VALUES(74, 8, 'Košice - okolie');
INSERT INTO COKRES VALUES(75, 8, 'Michalovce');
INSERT INTO COKRES VALUES(76, 8, 'Rožňava');
INSERT INTO COKRES VALUES(77, 8, 'Sobrance');
INSERT INTO COKRES VALUES(78, 8, 'Spišská Nová Ves');
INSERT INTO COKRES VALUES(79, 8, 'Trebišov');
--DROP TABLE COBEC;
CREATE TABLE COBEC
(
ID_OBEC INT(10) PRIMARY KEY,
NAZOV_OBEC VARCHAR(80),
ID_OKRES INT NOT NULL,
ID_KRAJ INT NOT NULL
);
INSERT INTO COBEC VALUES(1, 'Vaďovce', 19, 3);
INSERT INTO COBEC VALUES(2, 'Veľká Hradná', 24, 3);
INSERT INTO COBEC VALUES(3, 'Veľké Bierovce', 24, 3);
INSERT INTO COBEC VALUES(4, 'Višňové', 19, 3);
INSERT INTO COBEC VALUES(5, 'Trnava', 15, 2);
INSERT INTO COBEC VALUES(6, 'Bíňovce', 15, 2);
INSERT INTO COBEC VALUES(7, 'Bohdanovce nad Trnavou', 15, 2);
INSERT INTO COBEC VALUES(8, 'Bojničky', 11, 2);
INSERT INTO COBEC VALUES(9, 'Boleráz', 15, 2);
INSERT INTO COBEC VALUES(10, 'Borová', 15, 2);
INSERT INTO COBEC VALUES(11, 'Borovce', 12, 2);
INSERT INTO COBEC VALUES(12, 'Brestovany', 15, 2);
INSERT INTO COBEC VALUES(13, 'Bučany', 15, 2);
INSERT INTO COBEC VALUES(14, 'Buková', 15, 2);
INSERT INTO COBEC VALUES(15, 'Cífer', 15, 2);
INSERT INTO COBEC VALUES(16, 'Červeník', 11, 2);
INSERT INTO COBEC VALUES(17, 'Dechtice', 15, 2);
INSERT INTO COBEC VALUES(18, 'Dolná Krupá', 15, 2);
INSERT INTO COBEC VALUES(19, 'Dolné Dubové', 15, 2);
INSERT INTO COBEC VALUES(20, 'Dolné Orešany', 15, 2);
INSERT INTO COBEC VALUES(21, 'Dolné Otrokovce', 11, 2);
INSERT INTO COBEC VALUES(22, 'Senec', 8, 1);
INSERT INTO COBEC VALUES(23, 'Slovenský Grob', 7, 1);
INSERT INTO COBEC VALUES(24, 'Stupava', 6, 1);
INSERT INTO COBEC VALUES(25, 'Suchohrad', 6, 1);
INSERT INTO COBEC VALUES(26, 'Šenkvice', 7, 1);
INSERT INTO COBEC VALUES(27, 'Štefanová', 7, 1);
INSERT INTO COBEC VALUES(28, 'Tomášov', 8, 1);
INSERT INTO COBEC VALUES(29, 'Tureň', 8, 1);
INSERT INTO COBEC VALUES(30, 'Veľký Biel', 8, 1);
INSERT INTO COBEC VALUES(31, 'Viničné', 7, 1);
INSERT INTO COBEC VALUES(32, 'Vinosady', 7, 1);
INSERT INTO COBEC VALUES(33, 'Vlky', 8, 1);
INSERT INTO COBEC VALUES(34, 'Vysoká pri Morave', 6, 1);
INSERT INTO COBEC VALUES(35, 'Záhorská Ves', 6, 1);
INSERT INTO COBEC VALUES(36, 'Zohor', 6, 1);
INSERT INTO COBEC VALUES(37, 'Banská Bystrica', 43, 6);
INSERT INTO COBEC VALUES(38, 'Bacúch', 45, 6);
INSERT INTO COBEC VALUES(39, 'Badín', 43, 6);
INSERT INTO COBEC VALUES(40, 'Beňuš', 45, 6);
INSERT INTO COBEC VALUES(41, 'Baláže', 43, 6);
INSERT INTO COBEC VALUES(42, 'Braväcovo', 45, 6);
INSERT INTO COBEC VALUES(43, 'Brezno', 45, 6);
INSERT INTO COBEC VALUES(44, 'Čierny Balog', 45, 6);
INSERT INTO COBEC VALUES(45, 'Dolná Lehota', 45, 6);
INSERT INTO COBEC VALUES(46, 'Dolná Mičiná', 43, 6);
INSERT INTO COBEC VALUES(47, 'Dolný Harmanec', 43, 6);
INSERT INTO COBEC VALUES(48, 'Donovaly', 43, 6);
INSERT INTO COBEC VALUES(49, 'Drábsko', 45, 6);
INSERT INTO COBEC VALUES(50, 'Dúbravica', 43, 6);
INSERT INTO COBEC VALUES(51, 'Harmanec', 43, 6);
INSERT INTO COBEC VALUES(52, 'Heľpa', 45, 6);
INSERT INTO COBEC VALUES(53, 'Hiadeľ', 43, 6);
INSERT INTO COBEC VALUES(54, 'Horná Mičiná', 43, 6);
INSERT INTO COBEC VALUES(55, 'Horné Pršany', 43, 6);
INSERT INTO COBEC VALUES(56, 'Hrochoť', 43, 6);
INSERT INTO COBEC VALUES(57, 'Hronec', 45, 6);
INSERT INTO COBEC VALUES(58, 'Brusno', 43, 6);
INSERT INTO COBEC VALUES(59, 'Jarabá', 45, 6);
INSERT INTO COBEC VALUES(60, 'Kordíky', 43, 6);
INSERT INTO COBEC VALUES(61, 'Králiky', 43, 6);
INSERT INTO COBEC VALUES(62, 'Lom nad Rimavicou', 45, 6);
INSERT INTO COBEC VALUES(63, 'Ľubietová', 43, 6);
INSERT INTO COBEC VALUES(64, 'Medzibrod', 43, 6);
INSERT INTO COBEC VALUES(65, 'Michalová', 45, 6);
INSERT INTO COBEC VALUES(66, 'Môlča', 43, 6);
INSERT INTO COBEC VALUES(67, 'Mýto pod Ďumbierom', 45, 6);
INSERT INTO COBEC VALUES(68, 'Nemecká', 45, 6);
INSERT INTO COBEC VALUES(69, 'Oravce', 43, 6);
INSERT INTO COBEC VALUES(70, 'Podbrezová', 45, 6);
INSERT INTO COBEC VALUES(71, 'Podkonice', 43, 6);
INSERT INTO COBEC VALUES(72, 'Pohorelá', 45, 6);
INSERT INTO COBEC VALUES(73, 'Pohronská Polhora', 45, 6);
INSERT INTO COBEC VALUES(74, 'Polomka', 45, 6);
INSERT INTO COBEC VALUES(75, 'Poniky', 43, 6);
INSERT INTO COBEC VALUES(76, 'Povrazník', 43, 6);
INSERT INTO COBEC VALUES(77, 'Predajná', 45, 6);
INSERT INTO COBEC VALUES(78, 'Ráztoka', 45, 6);
INSERT INTO COBEC VALUES(79, 'Sebedín - Bečov', 43, 6);
INSERT INTO COBEC VALUES(80, 'Selce', 43, 6);
INSERT INTO COBEC VALUES(81, 'Sihla', 45, 6);
INSERT INTO COBEC VALUES(82, 'Staré Hory', 43, 6);
INSERT INTO COBEC VALUES(83, 'Strelníky', 43, 6);
INSERT INTO COBEC VALUES(84, 'Špania Dolina', 43, 6);
INSERT INTO COBEC VALUES(85, 'Šumiac', 45, 6);
INSERT INTO COBEC VALUES(86, 'Telgárt', 45, 6);
INSERT INTO COBEC VALUES(87, 'Tajov', 43, 6);
INSERT INTO COBEC VALUES(88, 'Vaľkovňa', 45, 6);
INSERT INTO COBEC VALUES(89, 'Závadka nad Hronom', 45, 6);
INSERT INTO COBEC VALUES(90, 'Dlhá nad Kysucou', 33, 5);
INSERT INTO COBEC VALUES(91, 'Dolný Vadičov', 35, 5);
INSERT INTO COBEC VALUES(92, 'Dunajov', 33, 5);
INSERT INTO COBEC VALUES(93, 'Klokočov', 33, 5);
INSERT INTO COBEC VALUES(94, 'Klubina', 33, 5);
INSERT INTO COBEC VALUES(95, 'Korňa', 33, 5);
INSERT INTO COBEC VALUES(96, 'Krásno nad Kysucou', 33, 5);
INSERT INTO COBEC VALUES(97, 'Kysucké Nové Mesto', 35, 5);
INSERT INTO COBEC VALUES(98, 'Lodno', 35, 5);
INSERT INTO COBEC VALUES(99, 'Lopušné Pažite', 35, 5);
INSERT INTO COBEC VALUES(100, 'Nesluša', 35, 5);
INSERT INTO COBEC VALUES(101, 'Nová Bystrica', 33, 5);
INSERT INTO COBEC VALUES(102, 'Ochodnica', 35, 5);
INSERT INTO COBEC VALUES(103, 'Pochabany', 16, 3);
INSERT INTO COBEC VALUES(104, 'Jesenské', 26, 4);
INSERT INTO COBEC VALUES(105, 'Malé Chyndice', 27, 4);
INSERT INTO COBEC VALUES(106, 'Borčany', 16, 3);
INSERT INTO COBEC VALUES(107, 'Ižipovce', 36, 5);
INSERT INTO COBEC VALUES(108, 'Medzany', 62, 7);
INSERT INTO COBEC VALUES(109, 'Bystrá', 45, 6);
INSERT INTO COBEC VALUES(110, 'Kynceľová', 43, 6);
INSERT INTO COBEC VALUES(111, 'Nemce', 43, 6);
INSERT INTO COBEC VALUES(112, 'Vlkanová', 43, 6);
INSERT INTO COBEC VALUES(113, 'Vidiná', 48, 6);
INSERT INTO COBEC VALUES(114, 'Biskupice', 48, 6);
INSERT INTO COBEC VALUES(115, 'Ďubákovo', 49, 6);
INSERT INTO COBEC VALUES(116, 'Gregorova Vieska', 48, 6);
INSERT INTO COBEC VALUES(117, 'Trenč', 48, 6);
INSERT INTO COBEC VALUES(118, 'Vrútky', 37, 5);
INSERT INTO COBEC VALUES(119, 'Borčice', 17, 3);
INSERT INTO COBEC VALUES(120, 'Kameničany', 17, 3);
INSERT INTO COBEC VALUES(121, 'Slavnica', 17, 3);
INSERT INTO COBEC VALUES(122, 'Dolné Kočkovce', 23, 3);
INSERT INTO COBEC VALUES(123, 'Nimnica', 23, 3);
INSERT INTO COBEC VALUES(124, 'Streženice', 23, 3);
INSERT INTO COBEC VALUES(125, 'Slopná', 21, 3);
INSERT INTO COBEC VALUES(126, 'Vydrná', 23, 3);
INSERT INTO COBEC VALUES(127, 'Kvašov', 23, 3);
INSERT INTO COBEC VALUES(128, 'Hatné', 21, 3);
INSERT INTO COBEC VALUES(129, 'Klieština', 21, 3);
INSERT INTO COBEC VALUES(130, 'Čelkova Lehota', 21, 3);
INSERT INTO COBEC VALUES(131, 'Malé Lednice', 21, 3);
INSERT INTO COBEC VALUES(132, 'Sádočné', 21, 3);
INSERT INTO COBEC VALUES(133, 'Krivoklát', 17, 3);
INSERT INTO COBEC VALUES(134, 'Vršatské Podhradie', 17, 3);
INSERT INTO COBEC VALUES(135, 'Bodiná', 21, 3);
INSERT INTO COBEC VALUES(136, 'Horná Breznica', 23, 3);
INSERT INTO COBEC VALUES(137, 'Lipník', 22, 3);
INSERT INTO COBEC VALUES(138, 'Jalovec', 22, 3);
INSERT INTO COBEC VALUES(139, 'Abovce', 51, 6);
INSERT INTO COBEC VALUES(140, 'Riečka', 51, 6);
INSERT INTO COBEC VALUES(141, 'Nižný Skálnik', 51, 6);
INSERT INTO COBEC VALUES(142, 'Rimavské Zalužany', 51, 6);
INSERT INTO COBEC VALUES(143, 'Sása', 50, 6);
INSERT INTO COBEC VALUES(144, 'Gemerské Michalovce', 51, 6);
INSERT INTO COBEC VALUES(145, 'Vyšné Valice', 51, 6);
INSERT INTO COBEC VALUES(146, 'Dulovo', 51, 6);
INSERT INTO COBEC VALUES(147, 'Zacharovce', 51, 6);
INSERT INTO COBEC VALUES(148, 'Lietavská Lúčka', 42, 5);
INSERT INTO COBEC VALUES(149, 'Porúbka', 42, 5);
INSERT INTO COBEC VALUES(150, 'Ďurčiná', 42, 5);
INSERT INTO COBEC VALUES(151, 'Kľače', 42, 5);
INSERT INTO COBEC VALUES(152, 'Lukavica', 53, 6);
INSERT INTO COBEC VALUES(153, 'Lieskovec', 53, 6);
INSERT INTO COBEC VALUES(154, 'Nezbudská Lúčka', 42, 5);
INSERT INTO COBEC VALUES(155, 'Malé Straciny', 52, 6);
INSERT INTO COBEC VALUES(156, 'Veľké Straciny', 52, 6);
INSERT INTO COBEC VALUES(157, 'Počarová', 21, 3);
INSERT INTO COBEC VALUES(158, 'Bulhary', 48, 6);
INSERT INTO COBEC VALUES(159, 'Liptovská Porúbka', 36, 5);
INSERT INTO COBEC VALUES(160, 'Ivanka pri Nitre', 27, 4);
INSERT INTO COBEC VALUES(161, 'Ducové', 12, 2);
INSERT INTO COBEC VALUES(162, 'Bašovce', 12, 2);
INSERT INTO COBEC VALUES(163, 'Šípkové', 12, 2);
INSERT INTO COBEC VALUES(164, 'Jasenov', 57, 7);
INSERT INTO COBEC VALUES(165, 'Hažín nad Cirochou', 57, 7);
INSERT INTO COBEC VALUES(166, 'Rokytovce', 60, 7);
INSERT INTO COBEC VALUES(167, 'Sopkovce', 57, 7);
INSERT INTO COBEC VALUES(168, 'Maškovce', 57, 7);
INSERT INTO COBEC VALUES(169, 'Kechnec', 74, 8);
INSERT INTO COBEC VALUES(170, 'Turňa nad Bodvou', 74, 8);
INSERT INTO COBEC VALUES(171, 'Bočiar', 74, 8);
INSERT INTO COBEC VALUES(172, 'Sokoľany', 74, 8);
INSERT INTO COBEC VALUES(173, 'Dvorníky - Včeláre', 74, 8);
INSERT INTO COBEC VALUES(174, 'Zádiel', 74, 8);
INSERT INTO COBEC VALUES(175, 'Štôla', 61, 7);
INSERT INTO COBEC VALUES(176, 'Malá Franková', 58, 7);
INSERT INTO COBEC VALUES(177, 'Lipníky', 62, 7);
INSERT INTO COBEC VALUES(178, 'Suchá Dolina', 62, 7);
INSERT INTO COBEC VALUES(179, 'Čučma', 76, 8);
INSERT INTO COBEC VALUES(180, 'Jovice', 76, 8);
INSERT INTO COBEC VALUES(181, 'Kružná', 76, 8);
INSERT INTO COBEC VALUES(182, 'Vyšný Hrabovec', 66, 7);
INSERT INTO COBEC VALUES(183, 'Vysoké Tatry', 61, 7);
INSERT INTO COBEC VALUES(184, 'Smižany', 78, 8);
INSERT INTO COBEC VALUES(185, 'Hronsek', 43, 6);
INSERT INTO COBEC VALUES(186, 'Malachov', 43, 6);
INSERT INTO COBEC VALUES(187, 'Milhosť', 74, 8);
INSERT INTO COBEC VALUES(188, 'Liptovský Peter', 36, 5);
INSERT INTO COBEC VALUES(189, 'Mikušovce', 48, 6);
INSERT INTO COBEC VALUES(190, 'Babindol', 27, 4);
INSERT INTO COBEC VALUES(191, 'Korytné', 59, 7);
INSERT INTO COBEC VALUES(192, 'Hencovce', 68, 7);
INSERT INTO COBEC VALUES(193, 'Štefanovičová', 27, 4);
INSERT INTO COBEC VALUES(194, 'Kuzmice', 30, 4);
INSERT INTO COBEC VALUES(195, 'Šuja', 42, 5);
INSERT INTO COBEC VALUES(196, 'Horná Ves', 55, 6);
INSERT INTO COBEC VALUES(197, 'Hlboké nad Váhom', 32, 5);
INSERT INTO COBEC VALUES(198, 'Vyšný Medzev', 74, 8);
INSERT INTO COBEC VALUES(199, 'Lackovce', 57, 7);
INSERT INTO COBEC VALUES(200, 'Bohunice', 17, 3);
INSERT INTO COBEC VALUES(201, 'Čab', 27, 4);
INSERT INTO COBEC VALUES(202, 'Dolné Lefantovce', 27, 4);
INSERT INTO COBEC VALUES(203, 'Kostoľany nad Hornádom', 74, 8);
INSERT INTO COBEC VALUES(204, 'Nový Svet', 8, 1);
INSERT INTO COBEC VALUES(205, 'Neverice', 31, 4);
--VYTVORENIE TABULKY PRE SEQUENCIU, GENEROVANIE NOVEHO ID PRE MYSQL
create table All_Sequence(
seq_name varchar(30),
start int,
increment int,
currval int,
flag char(1));
--VYTVORENIE PROCEDURY SEQUENCIE
CREATE DEFINER = 'root'@'localhost'
PROCEDURE Get_Sequence(
in SeqName varchar(255),
out NextVal int
)
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
begin
declare rowcount int;
declare v_flag char(1);
select Count(*) into rowcount from All_Sequence where seq_name=SeqName;
if rowcount=0 then
insert into All_Sequence values(SeqName,1,1,1,'A');
set NextVal = 1;
else
set v_flag='N';
while (v_flag='N') do
select flag into v_flag from All_Sequence where seq_name=SeqName;
end while;
update All_Sequence set flag='N' where seq_name=SeqName;
select currval+INCREMENT into NextVal from All_Sequence where seq_name=SeqName;
update All_Sequence set flag='A',currval=NextVal where seq_name=SeqName;
end if;
end;
COMMIT;