SlideShare uma empresa Scribd logo
1 de 17
CREATE TABLE camioneros 
( 
nombre CHAR(18) NULL , 
cedula CHAR(18) NOT NULL , 
telefono CHAR(18) NULL , 
direccion CHAR(18) NULL , 
salario CHAR(18) NULL , 
destinatario CHAR(18) NULL , 
matricula CHAR(18) NULL 
); 
CREATE UNIQUE INDEX XPKcamioneros ON camioneros 
(cedula ASC);
ALTER TABLE camioneros 
ADD CONSTRAINT XPKcamioneros PRIMARY KEY (cedula); 
CREATE TABLE camiones 
( 
matricula CHAR(18) NOT NULL , 
modelo CHAR(18) NULL , 
tipo CHAR(18) NULL , 
potencia CHAR(18) NULL 
); 
CREATE UNIQUE INDEX XPKcamiones ON camiones 
(matricula ASC); 
ALTER TABLE camiones 
ADD CONSTRAINT XPKcamiones PRIMARY KEY (matricula);
CREATE TABLE paquete 
( 
codigo CHAR(18) NOT NULL , 
provincia CHAR(18) NULL , 
nombre CHAR(18) NULL , 
cedula CHAR(18) NULL 
); 
CREATE UNIQUE INDEX XPKpaquete ON paquete 
(codigo ASC); 
ALTER TABLE paquete 
ADD CONSTRAINT XPKpaquete PRIMARY KEY (codigo); 
CREATE TABLE provincias 
( 
codigo CHAR(18) NOT NULL , 
nombre CHAR(18) NULL 
);
CREATE UNIQUE INDEX XPKprovincias ON provincias 
(codigo ASC); 
ALTER TABLE provincias 
ADD CONSTRAINT XPKprovincias PRIMARY KEY (codigo); 
ALTER TABLE camioneros 
ADD (CONSTRAINT R_4 FOREIGN KEY (matricula) REFERENCES camiones (matricula) ON DELETE SET NULL); 
ALTER TABLE paquete 
ADD (CONSTRAINT R_3 FOREIGN KEY (codigo) REFERENCES provincias (codigo)); 
ALTER TABLE paquete 
ADD (CONSTRAINT R_5 FOREIGN KEY (cedula) REFERENCES camioneros (cedula) ON DELETE SET NULL);
CREATE TRIGGER tI_camioneros BEFORE INSERT ON camioneros for each row 
-- ERwin Builtin Trigger 
-- INSERT trigger on camioneros 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* camiones camioneros on child insert set null */ 
/* ERWIN_RELATION:CHECKSUM="0000ef67", PARENT_OWNER="", PARENT_TABLE="camiones" 
CHILD_OWNER="", CHILD_TABLE="camioneros" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ 
UPDATE camioneros 
SET 
/* %SetFK(camioneros,NULL) */ 
camioneros.matricula = NULL 
WHERE 
NOT EXISTS ( 
SELECT * FROM camiones 
WHERE 
/* %JoinFKPK(:%New,camiones," = "," AND") */ 
:new.matricula = camiones.matricula 
) 
/* %JoinPKPK(camioneros,:%New," = "," AND") */ 
and camioneros.cedula = :new.cedula;
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tD_camioneros AFTER DELETE ON camioneros for each row 
-- ERwin Builtin Trigger 
-- DELETE trigger on camioneros 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* camioneros paquete on parent delete set null */ 
/* ERWIN_RELATION:CHECKSUM="0000abe1", PARENT_OWNER="", PARENT_TABLE="camioneros" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ 
UPDATE paquete 
SET 
/* %SetFK(paquete,NULL) */ 
paquete.cedula = NULL 
WHERE 
/* %JoinFKPK(paquete,:%Old," = "," AND") */ 
paquete.cedula = :old.cedula;
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tU_camioneros AFTER UPDATE ON camioneros for each row 
-- ERwin Builtin Trigger 
-- UPDATE trigger on camioneros 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* camioneros paquete on parent update set null */ 
/* ERWIN_RELATION:CHECKSUM="0001e0e9", PARENT_OWNER="", PARENT_TABLE="camioneros" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ 
IF 
/* %JoinPKPK(:%Old,:%New," <> "," OR ") */ 
:old.cedula <> :new.cedula 
THEN 
UPDATE paquete 
SET 
/* %SetFK(paquete,NULL) */ 
paquete.cedula = NULL 
WHERE 
/* %JoinFKPK(paquete,:%Old," = ",",") */ 
paquete.cedula = :old.cedula; 
END IF;
/* ERwin Builtin Trigger */ 
/* camiones camioneros on child update no action */ 
/* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camiones" 
CHILD_OWNER="", CHILD_TABLE="camioneros" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ 
SELECT count(*) INTO NUMROWS 
FROM camiones 
WHERE 
/* %JoinFKPK(:%New,camiones," = "," AND") */ 
:new.matricula = camiones.matricula; 
IF ( 
/* %NotnullFK(:%New," IS NOT NULL AND") */ 
:new.matricula IS NOT NULL AND 
NUMROWS = 0 
) 
THEN 
raise_application_error( 
-20007, 
'Cannot update camioneros because camiones does not exist.' 
); 
END IF; 
-- ERwin Builtin Trigger
END; 
/ 
CREATE TRIGGER tD_camiones AFTER DELETE ON camiones for each row 
-- ERwin Builtin Trigger 
-- DELETE trigger on camiones 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* camiones camioneros on parent delete set null */ 
/* ERWIN_RELATION:CHECKSUM="0000b734", PARENT_OWNER="", PARENT_TABLE="camiones" 
CHILD_OWNER="", CHILD_TABLE="camioneros" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ 
UPDATE camioneros 
SET 
/* %SetFK(camioneros,NULL) */ 
camioneros.matricula = NULL 
WHERE 
/* %JoinFKPK(camioneros,:%Old," = "," AND") */ 
camioneros.matricula = :old.matricula; 
-- ERwin Builtin Trigger 
END;
/ 
CREATE TRIGGER tU_camiones AFTER UPDATE ON camiones for each row 
-- ERwin Builtin Trigger 
-- UPDATE trigger on camiones 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* camiones camioneros on parent update set null */ 
/* ERWIN_RELATION:CHECKSUM="0000d8e3", PARENT_OWNER="", PARENT_TABLE="camiones" 
CHILD_OWNER="", CHILD_TABLE="camioneros" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ 
IF 
/* %JoinPKPK(:%Old,:%New," <> "," OR ") */ 
:old.matricula <> :new.matricula 
THEN 
UPDATE camioneros 
SET 
/* %SetFK(camioneros,NULL) */ 
camioneros.matricula = NULL 
WHERE 
/* %JoinFKPK(camioneros,:%Old," = ",",") */ 
camioneros.matricula = :old.matricula; 
END IF;
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tI_paquete BEFORE INSERT ON paquete for each row 
-- ERwin Builtin Trigger 
-- INSERT trigger on paquete 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* provincias paquete on child insert restrict */ 
/* ERWIN_RELATION:CHECKSUM="0001e783", PARENT_OWNER="", PARENT_TABLE="provincias" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ 
SELECT count(*) INTO NUMROWS 
FROM provincias 
WHERE 
/* %JoinFKPK(:%New,provincias," = "," AND") */ 
:new.codigo = provincias.codigo; 
IF ( 
/* %NotnullFK(:%New," IS NOT NULL AND") */ 
NUMROWS = 0 
)
THEN 
raise_application_error( 
-20002, 
'Cannot insert paquete because provincias does not exist.' 
); 
END IF; 
/* ERwin Builtin Trigger */ 
/* camioneros paquete on child insert set null */ 
/* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camioneros" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ 
UPDATE paquete 
SET 
/* %SetFK(paquete,NULL) */ 
paquete.cedula = NULL 
WHERE 
NOT EXISTS ( 
SELECT * FROM camioneros 
WHERE 
/* %JoinFKPK(:%New,camioneros," = "," AND") */ 
:new.cedula = camioneros.cedula 
) 
/* %JoinPKPK(paquete,:%New," = "," AND") */ 
and paquete.codigo = :new.codigo;
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tU_paquete AFTER UPDATE ON paquete for each row 
-- ERwin Builtin Trigger 
-- UPDATE trigger on paquete 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* provincias paquete on child update restrict */ 
/* ERWIN_RELATION:CHECKSUM="0002069f", PARENT_OWNER="", PARENT_TABLE="provincias" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ 
SELECT count(*) INTO NUMROWS 
FROM provincias 
WHERE 
/* %JoinFKPK(:%New,provincias," = "," AND") */ 
:new.codigo = provincias.codigo; 
IF ( 
/* %NotnullFK(:%New," IS NOT NULL AND") */ 
NUMROWS = 0
) 
THEN 
raise_application_error( 
-20007, 
'Cannot update paquete because provincias does not exist.' 
); 
END IF; 
/* ERwin Builtin Trigger */ 
/* camioneros paquete on child update no action */ 
/* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camioneros" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ 
SELECT count(*) INTO NUMROWS 
FROM camioneros 
WHERE 
/* %JoinFKPK(:%New,camioneros," = "," AND") */ 
:new.cedula = camioneros.cedula; 
IF ( 
/* %NotnullFK(:%New," IS NOT NULL AND") */ 
:new.cedula IS NOT NULL AND 
NUMROWS = 0 
) 
THEN 
raise_application_error(
-20007, 
'Cannot update paquete because camioneros does not exist.' 
); 
END IF; 
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tD_provincias AFTER DELETE ON provincias for each row 
-- ERwin Builtin Trigger 
-- DELETE trigger on provincias 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* provincias paquete on parent delete restrict */ 
/* ERWIN_RELATION:CHECKSUM="0000d337", PARENT_OWNER="", PARENT_TABLE="provincias" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ 
SELECT count(*) INTO NUMROWS 
FROM paquete 
WHERE 
/* %JoinFKPK(paquete,:%Old," = "," AND") */
paquete.codigo = :old.codigo; 
IF (NUMROWS > 0) 
THEN 
raise_application_error( 
-20001, 
'Cannot delete provincias because paquete exists.' 
); 
END IF; 
-- ERwin Builtin Trigger 
END; 
/ 
CREATE TRIGGER tU_provincias AFTER UPDATE ON provincias for each row 
-- ERwin Builtin Trigger 
-- UPDATE trigger on provincias 
DECLARE NUMROWS INTEGER; 
BEGIN 
/* ERwin Builtin Trigger */ 
/* provincias paquete on parent update restrict */ 
/* ERWIN_RELATION:CHECKSUM="0000fe23", PARENT_OWNER="", PARENT_TABLE="provincias" 
CHILD_OWNER="", CHILD_TABLE="paquete" 
P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", 
FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ 
IF
/* %JoinPKPK(:%Old,:%New," <> "," OR ") */ 
:old.codigo <> :new.codigo 
THEN 
SELECT count(*) INTO NUMROWS 
FROM paquete 
WHERE 
/* %JoinFKPK(paquete,:%Old," = "," AND") */ 
paquete.codigo = :old.codigo; 
IF (NUMROWS > 0) 
THEN 
raise_application_error( 
-20005, 
'Cannot update provincias because paquete exists.' 
); 
END IF; 
END IF; 
-- ERwin Builtin Trigger 
END; 
/

Mais conteúdo relacionado

Semelhante a Aviles manuel hurtado katherine

the following SPOOL command will capture the results of .docx
 the following SPOOL command will capture the results of    .docx the following SPOOL command will capture the results of    .docx
the following SPOOL command will capture the results of .docx
MARRY7
 
Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
Nur Khoiri
 
Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)
Marreddy P
 

Semelhante a Aviles manuel hurtado katherine (6)

the following SPOOL command will capture the results of .docx
 the following SPOOL command will capture the results of    .docx the following SPOOL command will capture the results of    .docx
the following SPOOL command will capture the results of .docx
 
#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx#include iostream #include string#includeiomanip using.docx
#include iostream #include string#includeiomanip using.docx
 
sas aeroplan sample
sas aeroplan samplesas aeroplan sample
sas aeroplan sample
 
#include iostream #include string #include fstream std.docx
#include iostream #include string #include fstream  std.docx#include iostream #include string #include fstream  std.docx
#include iostream #include string #include fstream std.docx
 
Example syntax alv grid list
Example syntax alv grid listExample syntax alv grid list
Example syntax alv grid list
 
Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

Aviles manuel hurtado katherine

  • 1. CREATE TABLE camioneros ( nombre CHAR(18) NULL , cedula CHAR(18) NOT NULL , telefono CHAR(18) NULL , direccion CHAR(18) NULL , salario CHAR(18) NULL , destinatario CHAR(18) NULL , matricula CHAR(18) NULL ); CREATE UNIQUE INDEX XPKcamioneros ON camioneros (cedula ASC);
  • 2. ALTER TABLE camioneros ADD CONSTRAINT XPKcamioneros PRIMARY KEY (cedula); CREATE TABLE camiones ( matricula CHAR(18) NOT NULL , modelo CHAR(18) NULL , tipo CHAR(18) NULL , potencia CHAR(18) NULL ); CREATE UNIQUE INDEX XPKcamiones ON camiones (matricula ASC); ALTER TABLE camiones ADD CONSTRAINT XPKcamiones PRIMARY KEY (matricula);
  • 3. CREATE TABLE paquete ( codigo CHAR(18) NOT NULL , provincia CHAR(18) NULL , nombre CHAR(18) NULL , cedula CHAR(18) NULL ); CREATE UNIQUE INDEX XPKpaquete ON paquete (codigo ASC); ALTER TABLE paquete ADD CONSTRAINT XPKpaquete PRIMARY KEY (codigo); CREATE TABLE provincias ( codigo CHAR(18) NOT NULL , nombre CHAR(18) NULL );
  • 4. CREATE UNIQUE INDEX XPKprovincias ON provincias (codigo ASC); ALTER TABLE provincias ADD CONSTRAINT XPKprovincias PRIMARY KEY (codigo); ALTER TABLE camioneros ADD (CONSTRAINT R_4 FOREIGN KEY (matricula) REFERENCES camiones (matricula) ON DELETE SET NULL); ALTER TABLE paquete ADD (CONSTRAINT R_3 FOREIGN KEY (codigo) REFERENCES provincias (codigo)); ALTER TABLE paquete ADD (CONSTRAINT R_5 FOREIGN KEY (cedula) REFERENCES camioneros (cedula) ON DELETE SET NULL);
  • 5. CREATE TRIGGER tI_camioneros BEFORE INSERT ON camioneros for each row -- ERwin Builtin Trigger -- INSERT trigger on camioneros DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* camiones camioneros on child insert set null */ /* ERWIN_RELATION:CHECKSUM="0000ef67", PARENT_OWNER="", PARENT_TABLE="camiones" CHILD_OWNER="", CHILD_TABLE="camioneros" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ UPDATE camioneros SET /* %SetFK(camioneros,NULL) */ camioneros.matricula = NULL WHERE NOT EXISTS ( SELECT * FROM camiones WHERE /* %JoinFKPK(:%New,camiones," = "," AND") */ :new.matricula = camiones.matricula ) /* %JoinPKPK(camioneros,:%New," = "," AND") */ and camioneros.cedula = :new.cedula;
  • 6. -- ERwin Builtin Trigger END; / CREATE TRIGGER tD_camioneros AFTER DELETE ON camioneros for each row -- ERwin Builtin Trigger -- DELETE trigger on camioneros DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* camioneros paquete on parent delete set null */ /* ERWIN_RELATION:CHECKSUM="0000abe1", PARENT_OWNER="", PARENT_TABLE="camioneros" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ UPDATE paquete SET /* %SetFK(paquete,NULL) */ paquete.cedula = NULL WHERE /* %JoinFKPK(paquete,:%Old," = "," AND") */ paquete.cedula = :old.cedula;
  • 7. -- ERwin Builtin Trigger END; / CREATE TRIGGER tU_camioneros AFTER UPDATE ON camioneros for each row -- ERwin Builtin Trigger -- UPDATE trigger on camioneros DECLARE NUMROWS INTEGER; BEGIN /* camioneros paquete on parent update set null */ /* ERWIN_RELATION:CHECKSUM="0001e0e9", PARENT_OWNER="", PARENT_TABLE="camioneros" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ IF /* %JoinPKPK(:%Old,:%New," <> "," OR ") */ :old.cedula <> :new.cedula THEN UPDATE paquete SET /* %SetFK(paquete,NULL) */ paquete.cedula = NULL WHERE /* %JoinFKPK(paquete,:%Old," = ",",") */ paquete.cedula = :old.cedula; END IF;
  • 8. /* ERwin Builtin Trigger */ /* camiones camioneros on child update no action */ /* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camiones" CHILD_OWNER="", CHILD_TABLE="camioneros" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ SELECT count(*) INTO NUMROWS FROM camiones WHERE /* %JoinFKPK(:%New,camiones," = "," AND") */ :new.matricula = camiones.matricula; IF ( /* %NotnullFK(:%New," IS NOT NULL AND") */ :new.matricula IS NOT NULL AND NUMROWS = 0 ) THEN raise_application_error( -20007, 'Cannot update camioneros because camiones does not exist.' ); END IF; -- ERwin Builtin Trigger
  • 9. END; / CREATE TRIGGER tD_camiones AFTER DELETE ON camiones for each row -- ERwin Builtin Trigger -- DELETE trigger on camiones DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* camiones camioneros on parent delete set null */ /* ERWIN_RELATION:CHECKSUM="0000b734", PARENT_OWNER="", PARENT_TABLE="camiones" CHILD_OWNER="", CHILD_TABLE="camioneros" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ UPDATE camioneros SET /* %SetFK(camioneros,NULL) */ camioneros.matricula = NULL WHERE /* %JoinFKPK(camioneros,:%Old," = "," AND") */ camioneros.matricula = :old.matricula; -- ERwin Builtin Trigger END;
  • 10. / CREATE TRIGGER tU_camiones AFTER UPDATE ON camiones for each row -- ERwin Builtin Trigger -- UPDATE trigger on camiones DECLARE NUMROWS INTEGER; BEGIN /* camiones camioneros on parent update set null */ /* ERWIN_RELATION:CHECKSUM="0000d8e3", PARENT_OWNER="", PARENT_TABLE="camiones" CHILD_OWNER="", CHILD_TABLE="camioneros" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_4", FK_COLUMNS="matricula" */ IF /* %JoinPKPK(:%Old,:%New," <> "," OR ") */ :old.matricula <> :new.matricula THEN UPDATE camioneros SET /* %SetFK(camioneros,NULL) */ camioneros.matricula = NULL WHERE /* %JoinFKPK(camioneros,:%Old," = ",",") */ camioneros.matricula = :old.matricula; END IF;
  • 11. -- ERwin Builtin Trigger END; / CREATE TRIGGER tI_paquete BEFORE INSERT ON paquete for each row -- ERwin Builtin Trigger -- INSERT trigger on paquete DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* provincias paquete on child insert restrict */ /* ERWIN_RELATION:CHECKSUM="0001e783", PARENT_OWNER="", PARENT_TABLE="provincias" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ SELECT count(*) INTO NUMROWS FROM provincias WHERE /* %JoinFKPK(:%New,provincias," = "," AND") */ :new.codigo = provincias.codigo; IF ( /* %NotnullFK(:%New," IS NOT NULL AND") */ NUMROWS = 0 )
  • 12. THEN raise_application_error( -20002, 'Cannot insert paquete because provincias does not exist.' ); END IF; /* ERwin Builtin Trigger */ /* camioneros paquete on child insert set null */ /* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camioneros" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ UPDATE paquete SET /* %SetFK(paquete,NULL) */ paquete.cedula = NULL WHERE NOT EXISTS ( SELECT * FROM camioneros WHERE /* %JoinFKPK(:%New,camioneros," = "," AND") */ :new.cedula = camioneros.cedula ) /* %JoinPKPK(paquete,:%New," = "," AND") */ and paquete.codigo = :new.codigo;
  • 13. -- ERwin Builtin Trigger END; / CREATE TRIGGER tU_paquete AFTER UPDATE ON paquete for each row -- ERwin Builtin Trigger -- UPDATE trigger on paquete DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* provincias paquete on child update restrict */ /* ERWIN_RELATION:CHECKSUM="0002069f", PARENT_OWNER="", PARENT_TABLE="provincias" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ SELECT count(*) INTO NUMROWS FROM provincias WHERE /* %JoinFKPK(:%New,provincias," = "," AND") */ :new.codigo = provincias.codigo; IF ( /* %NotnullFK(:%New," IS NOT NULL AND") */ NUMROWS = 0
  • 14. ) THEN raise_application_error( -20007, 'Cannot update paquete because provincias does not exist.' ); END IF; /* ERwin Builtin Trigger */ /* camioneros paquete on child update no action */ /* ERWIN_RELATION:CHECKSUM="00000000", PARENT_OWNER="", PARENT_TABLE="camioneros" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_5", FK_COLUMNS="cedula" */ SELECT count(*) INTO NUMROWS FROM camioneros WHERE /* %JoinFKPK(:%New,camioneros," = "," AND") */ :new.cedula = camioneros.cedula; IF ( /* %NotnullFK(:%New," IS NOT NULL AND") */ :new.cedula IS NOT NULL AND NUMROWS = 0 ) THEN raise_application_error(
  • 15. -20007, 'Cannot update paquete because camioneros does not exist.' ); END IF; -- ERwin Builtin Trigger END; / CREATE TRIGGER tD_provincias AFTER DELETE ON provincias for each row -- ERwin Builtin Trigger -- DELETE trigger on provincias DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* provincias paquete on parent delete restrict */ /* ERWIN_RELATION:CHECKSUM="0000d337", PARENT_OWNER="", PARENT_TABLE="provincias" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ SELECT count(*) INTO NUMROWS FROM paquete WHERE /* %JoinFKPK(paquete,:%Old," = "," AND") */
  • 16. paquete.codigo = :old.codigo; IF (NUMROWS > 0) THEN raise_application_error( -20001, 'Cannot delete provincias because paquete exists.' ); END IF; -- ERwin Builtin Trigger END; / CREATE TRIGGER tU_provincias AFTER UPDATE ON provincias for each row -- ERwin Builtin Trigger -- UPDATE trigger on provincias DECLARE NUMROWS INTEGER; BEGIN /* ERwin Builtin Trigger */ /* provincias paquete on parent update restrict */ /* ERWIN_RELATION:CHECKSUM="0000fe23", PARENT_OWNER="", PARENT_TABLE="provincias" CHILD_OWNER="", CHILD_TABLE="paquete" P2C_VERB_PHRASE="", C2P_VERB_PHRASE="", FK_CONSTRAINT="R_3", FK_COLUMNS="codigo" */ IF
  • 17. /* %JoinPKPK(:%Old,:%New," <> "," OR ") */ :old.codigo <> :new.codigo THEN SELECT count(*) INTO NUMROWS FROM paquete WHERE /* %JoinFKPK(paquete,:%Old," = "," AND") */ paquete.codigo = :old.codigo; IF (NUMROWS > 0) THEN raise_application_error( -20005, 'Cannot update provincias because paquete exists.' ); END IF; END IF; -- ERwin Builtin Trigger END; /