Commit 58991929 authored by Holger Brand's avatar Holger Brand
Browse files

Extend Oracle SQL-Script with sequence and trigger to enable DB-AutoIncement for Oracle.

Test insert of a new section of exisiting class was successfull.
parent fb9a035a
CREATE TABLE VIP2012_CLASSES
-- DROP SEQUENCE BRAND.S_CLASSES;
CREATE SEQUENCE BRAND.S_CLASSES
START WITH 0
MAXVALUE 9999999999999999999999999999
MINVALUE 0
NOCYCLE
NOCACHE
NOORDER;
-- DROP SEQUENCE BRAND.S_SECTIONS;
CREATE SEQUENCE BRAND.S_SECTIONS
START WITH 0
MAXVALUE 9999999999999999999999999999
MINVALUE 0
NOCYCLE
NOCACHE
NOORDER;
-- DROP SEQUENCE BRAND.S_ITEMS;
CREATE SEQUENCE BRAND.S_ITEMS
START WITH 0
MAXVALUE 9999999999999999999999999999
MINVALUE 0
NOCYCLE
NOCACHE
NOORDER;
-- DROP SEQUENCE BRAND.S_ITEMVALUES;
CREATE SEQUENCE BRAND.S_ITEMVALUES
START WITH 16
MAXVALUE 9999999999999999999999999999
MINVALUE 0
NOCYCLE
NOCACHE
NOORDER;
-- ALTER TABLE BRAND.VIP2012_CLASSES
DROP PRIMARY KEY CASCADE;
-- DROP TABLE BRAND.VIP2012_CLASSES CASCADE CONSTRAINTS;
CREATE TABLE BRAND.VIP2012_CLASSES
(
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
PATH VARCHAR2(1024 CHAR) NOT NULL,
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
PATH VARCHAR2(1024 CHAR) NOT NULL,
ANCESTOR INTEGER
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE OR REPLACE TRIGGER BRAND.TR_CLASSES_ID
BEFORE INSERT OR UPDATE ON BRAND.VIP2012_CLASSES
FOR EACH ROW
DECLARE
tmpVar NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.id IS NULL THEN
SELECT s_classes.NEXTVAL INTO tmpVar FROM dual;
:NEW.id := tmpVar;
END IF;
END IF;
ANCESTOR INTEGER
);
END tr_classes_ID;
ALTER TABLE VIP2012_CLASSES ADD (
ALTER TABLE BRAND.VIP2012_CLASSES ADD (
PRIMARY KEY
(ID)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE);
ALTER TABLE VIP2012_CLASSES ADD (
ALTER TABLE BRAND.VIP2012_CLASSES ADD (
FOREIGN KEY (ANCESTOR)
REFERENCES VIP2012_CLASSES (ID)
REFERENCES BRAND.VIP2012_CLASSES (ID)
ENABLE VALIDATE);
-- ALTER TABLE BRAND.VIP2012_SECTIONS
DROP PRIMARY KEY CASCADE;
-- DROP TABLE BRAND.VIP2012_SECTIONS CASCADE CONSTRAINTS;
CREATE TABLE VIP2012_SECTIONS
CREATE TABLE BRAND.VIP2012_SECTIONS
(
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
FK_CLASSES INTEGER NOT NULL
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE OR REPLACE TRIGGER BRAND.TR_SECTIONS_ID
BEFORE INSERT OR UPDATE ON BRAND.VIP2012_SECTIONS
FOR EACH ROW
DECLARE
tmpVar NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.id IS NULL THEN
SELECT s_sections.NEXTVAL INTO tmpVar FROM dual;
:NEW.id := tmpVar;
END IF;
END IF;
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
FK_CLASSES INTEGER NOT NULL
);
END tr_sections_ID;
ALTER TABLE VIP2012_SECTIONS ADD (
ALTER TABLE BRAND.VIP2012_SECTIONS ADD (
PRIMARY KEY
(ID)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE);
ALTER TABLE VIP2012_SECTIONS ADD (
ALTER TABLE BRAND.VIP2012_SECTIONS ADD (
FOREIGN KEY (FK_CLASSES)
REFERENCES VIP2012_CLASSES (ID)
REFERENCES BRAND.VIP2012_CLASSES (ID)
ENABLE VALIDATE);
-- ALTER TABLE BRAND.VIP2012_ITEMS
DROP PRIMARY KEY CASCADE;
-- DROP TABLE BRAND.VIP2012_ITEMS CASCADE CONSTRAINTS;
CREATE TABLE VIP2012_ITEMS
CREATE TABLE BRAND.VIP2012_ITEMS
(
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
FK_CLASSES INTEGER NOT NULL,
FK_BASECLASS INTEGER NOT NULL
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE OR REPLACE TRIGGER BRAND.TR_ITEMS_ID
BEFORE INSERT OR UPDATE ON BRAND.VIP2012_ITEMS
FOR EACH ROW
DECLARE
tmpVar NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.id IS NULL THEN
SELECT s_items.NEXTVAL INTO tmpVar FROM dual;
:NEW.id := tmpVar;
END IF;
END IF;
ID INTEGER NOT NULL,
NAME VARCHAR2(255 CHAR) NOT NULL,
FK_CLASSES INTEGER NOT NULL,
FK_BASECLASS INTEGER NOT NULL
);
END tr_items_ID;
ALTER TABLE VIP2012_ITEMS ADD (
ALTER TABLE BRAND.VIP2012_ITEMS ADD (
PRIMARY KEY
(ID)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE,
UNIQUE (FK_BASECLASS, NAME)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE);
ALTER TABLE VIP2012_ITEMS ADD (
ALTER TABLE BRAND.VIP2012_ITEMS ADD (
FOREIGN KEY (FK_CLASSES)
REFERENCES VIP2012_CLASSES (ID)
REFERENCES BRAND.VIP2012_CLASSES (ID)
ENABLE VALIDATE,
FOREIGN KEY (FK_BASECLASS)
REFERENCES VIP2012_CLASSES (ID)
REFERENCES BRAND.VIP2012_CLASSES (ID)
ENABLE VALIDATE);
-- ALTER TABLE BRAND.VIP2012_ITEMVALUES
DROP PRIMARY KEY CASCADE;
-- DROP TABLE BRAND.VIP2012_ITEMVALUES CASCADE CONSTRAINTS;
CREATE TABLE VIP2012_ITEMVALUES
CREATE TABLE BRAND.VIP2012_ITEMVALUES
(
ID INTEGER NOT NULL,
FK_SECTIONS INTEGER NOT NULL,
FK_ITEMS INTEGER NOT NULL,
DATA VARCHAR2(1024 CHAR)
)
TABLESPACE USERS
RESULT_CACHE (MODE DEFAULT)
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE OR REPLACE TRIGGER BRAND.TR_ITEMVALUES_ID
BEFORE INSERT OR UPDATE ON BRAND.VIP2012_ITEMVALUES
FOR EACH ROW
DECLARE
tmpVar NUMBER;
BEGIN
IF INSERTING THEN
IF :NEW.id IS NULL THEN
SELECT s_itemvalues.NEXTVAL INTO tmpVar FROM dual;
:NEW.id := tmpVar;
END IF;
END IF;
ID INTEGER NOT NULL,
FK_SECTIONS INTEGER NOT NULL,
FK_ITEMS INTEGER NOT NULL,
DATA VARCHAR2(1024 CHAR)
);
END tr_itemvalues_ID;
ALTER TABLE VIP2012_ITEMVALUES ADD (
ALTER TABLE BRAND.VIP2012_ITEMVALUES ADD (
PRIMARY KEY
(ID)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE,
UNIQUE (FK_SECTIONS, FK_ITEMS)
USING INDEX
TABLESPACE USERS
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
ENABLE VALIDATE);
ALTER TABLE VIP2012_ITEMVALUES ADD (
ALTER TABLE BRAND.VIP2012_ITEMVALUES ADD (
FOREIGN KEY (FK_SECTIONS)
REFERENCES VIP2012_SECTIONS (ID)
REFERENCES BRAND.VIP2012_SECTIONS (ID)
ENABLE VALIDATE,
FOREIGN KEY (FK_ITEMS)
REFERENCES VIP2012_ITEMS (ID)
REFERENCES BRAND.VIP2012_ITEMS (ID)
ENABLE VALIDATE);
-- DROP TABLE VIP2012_ITEMVALUES
-- DROP TABLE VIP2012_ITEMS
-- DROP TABLE VIP2012_SECTIONS
-- DROP TABLE VIP2012_CLASSES
......@@ -128,7 +128,7 @@ Die sprachspezifischen Genehmigungen und Beschränkungen unter der Lizenz sind d
<Property Name="INST_productName" Type="Str">EUPL Templates</Property>
<Property Name="INST_productVersion" Type="Str">1.0.0</Property>
<Property Name="InstSpecBitness" Type="Str">32-bit</Property>
<Property Name="InstSpecVersion" Type="Str">12008026</Property>
<Property Name="InstSpecVersion" Type="Str">12008029</Property>
<Property Name="MSI_arpCompany" Type="Str">GSI Helmholtzzentrum für Schwerionenforschung GmbH</Property>
<Property Name="MSI_arpPhone" Type="Str">+49 6159 71 0</Property>
<Property Name="MSI_arpURL" Type="Str">http://www.gsi.de</Property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment