I have a database user that contains four tables department, employee, address and contact info, then stored 5 Records in each table, and wrote the PL/SQL Statement for the following:
Stored a record into employee, address and contact using trigger.
the insert into view is not working ! it results in error ? can you guys help me with this ?
this is my code :
-- Create Tables :
CREATE TABLE address (
code int primary key,
city varchar2(30),
street varchar2(30)
);
create table Department (
DepId int primary key ,
Dep_Name varchar2(30) ,
Dep_adress varchar(30));
create table Employee (
Emp_Id int primary key ,
firstName varchar2(30),
lastName varchar2(30),
salary int,
Dep_Id int references Department (DepId),
Code int references address (code));
CREATE TABLE contact_info (
email varchar2(30) primary key ,
phone int ,
EmpId int references Employee (Emp_Id));
-- insert :
insert into Department values (1,'IT','Amman');
insert into Department values (2,'CS','Jerash');
insert into Department values (3,'accounting','Amman');
insert into Department values (4,'managment','Amman');
insert into Department values (5,'employment','Amman');
insert into address values (50,'Amman','AAA');
insert into address values (60,'Amman','AAB');
insert into address values (70,'Amman','AAC');
insert into address values (80,'Jerash','AAD');
insert into address values (90,'Irbid','AAE');
insert into Employee (Emp_Id,firstName,lastName,salary,Dep_Id,Code) values (1,'john' , 'samo' , 1000 , (select DepId from Department where Dep_Name = 'IT'),(select code from address where street = 'AAA'));
insert into Employee (Emp_Id,firstName,lastName,salary,Dep_Id,Code) values (2,'mark' , 'wol' , 2000 , (select DepId from Department where Dep_Name = 'IT'),(select code from address where street = 'AAB'));
insert into Employee (Emp_Id,firstName,lastName,salary,Dep_Id,Code) values (3,'ahmad' , 'moh' , 1100 , (select DepId from Department where Dep_Name = 'IT'),(select code from address where street = 'AAC'));
insert into Employee (Emp_Id,firstName,lastName,salary,Dep_Id,Code) values (4,'maher' , 'imk' , 1700 , (select DepId from Department where Dep_Name = 'CS'),(select code from address where street = 'AAD'));
insert into Employee (Emp_Id,firstName,lastName,salary,Dep_Id,Code) values (5,'ali' , 'geh' , 1200 , (select DepId from Department where Dep_Name = 'CS'),(select code from address where street = 'AAE'));
insert into contact_info values ('john#gmail.com',0785602200, (select Emp_Id from Employee where salary = 1000));
insert into contact_info values ('mark#gmail.com',0785602201, (select Emp_Id from Employee where salary = 2000));
insert into contact_info values ('ahmad#gmail.com',0785602202, (select Emp_Id from Employee where salary = 1100));
insert into contact_info values ('maher#gmail.com',0785602203, (select Emp_Id from Employee where salary = 1700));
insert into contact_info values ('ali#gmail.com',0785602204, (select Emp_Id from Employee where salary = 1200));
-- trigger :
CREATE VIEW vw_address1 AS
SELECT
code,
city,
street
FROM
address;
CREATE OR REPLACE TRIGGER new_trg2
INSTEAD OF INSERT ON vw_address1
FOR EACH ROW
DECLARE
l_code NUMBER;
BEGIN
-- insert a new address first
INSERT INTO address(code,city, street)
VALUES(:NEW.code,:NEW.city, :NEW.street)
RETURNING code INTO l_code;
END;
insert into vw_address1(code,city,street) values (2,'Amman','AAB');
I am new to Oracle. The Oracle live SQL shorthand gave ready-made code on the departments and employees model.
I don't understand why the code is not viewing any table although I wrote a select statement. I don't understand the execution protocol.
link
create table departments (
name varchar2(255) not null,
location varchar2(4000),
country varchar2(4000)
)
;
create table employees (
department_id number
constraint employees_department_id_fk
references departments on delete cascade,
name varchar2(50) not null,
email varchar2(255),
cost_center number,
date_hired date,
job varchar2(255)
)
;
insert into departments (
name,
location,
country
) values (
'Security',
'Tanquecitos',
'United States'
);
insert into departments (
name,
location,
country
) values (
'Travel',
'Sugarloaf',
'United States'
);
insert into departments (
name,
location,
country
) values (
'Office of the CEO',
'Dale City',
'United States'
);
insert into departments (
name,
location,
country
) values (
'Security',
'Grosvenor',
'United States'
);
commit;
-- load data
insert into employees (
department_id,
name,
email,
cost_center,
date_hired,
job
) values (
1,
'Gricelda Luebbers',
'gricelda.luebbers#aaab.com',
20,
sysdate - 94,
'Systems Designer'
);
insert into employees (
department_id,
name,
email,
cost_center,
date_hired,
job
) values (
1,
'Dean Bollich',
'dean.bollich#aaac.com',
11,
sysdate - 74,
'Legal Assistant'
);
insert into employees (
department_id,
name,
email,
cost_center,
date_hired,
job
) values (
1,
'Milo Manoni',
'milo.manoni#aaad.com',
21,
sysdate - 68,
'Systems Designer'
);
insert into employees (
department_id,
name,
email,
cost_center,
date_hired,
job
) values (
1,
'Laurice Karl',
'laurice.karl#aaae.com',
78,
sysdate - 73,
'Programmer'
);
select
departments.name department_name,
departments.location location,
departments.country country,
employees.name employee_name,
employees.email email,
employees.cost_center cost_center,
employees.date_hired date_hired,
employees.job job
from
departments,
employees;
This is the output they are showing after running:
Table created.
ORA-02268: referenced table does not have a primary key
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
Statement processed.
ORA-00942: table or view does not exist
ORA-00942: table or view does not exist
ORA-00942: table or view does not exist
ORA-00942: table or view does not exist
ORA-00942: table or view does not exist
Your table departments does not have a primary key, so the constraint in table employees produces an error, and the table employees is not created.
You should refactor your SQL code, adding a proper primary key to the table involved and manage the insert value properly:
create table departments (
id numeric(10) not null
name varchar2(255) not null,
location varchar2(4000),
country varchar2(4000),
CONSTRAINT id PRIMARY KEY (id)
)
;
A nurse orders medical supplies via a requisition to one of three different supplies, all supplied by a supplier.
Nurse > Requisition < Supplies (3 kinds) < Supplier
Since items can be one of three kinds and a requisition may not exist yet for an item, the requisition table has the foreign keys of the 3 supply types.
The issue: my correctly listed foreign keys all point to 3 different tables, all but one of which will not have a corresponding foreign key for each entry.
I get the following error:
ERROR at line 1: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (MMM1339.ITEMNO_PHAR_FK) violated - parent key not found
CREATE TABLE SUPPLIER
(SUPPLIERNO INT,
SUPPLIERNAME VARCHAR2(100),
PHONENO VARCHAR2(12),
ADDRESS VARCHAR(100),
FAXNO VARCHAR(12),
CONSTRAINT SUPPLIERNO_SSPL_PK PRIMARY KEY(SUPPLIERNO));
CREATE TABLE SUPPLIES_PHARMACEUTICAL
(ITEMNO INT,
SUPPLIERNO INT,
NAME VARCHAR2(25),
DESCRIPTION VARCHAR2(25),
QUANTITYINSTOCK INT,
REORDERLEVEL INT,
COSTPERUNIT DECIMAL(6,2),
DOSAGE VARCHAR2(12),
CONSTRAINT ITEMNO_PHAR_PK PRIMARY KEY(ITEMNO));
CREATE TABLE SUPPLIES_SURGICAL
(ITEMNO INT,
NAME VARCHAR2(25),
DESCRIPTION VARCHAR2(25),
QUANTITYINSTOCK INT,
REORDERLEVEL INT,
COSTPERUNIT DECIMAL(6,2),
SUPPLIERNO INT,
CONSTRAINT ITEMNO_SUP_PK PRIMARY KEY(ITEMNO));
CREATE TABLE SUPPLIES_NONSURGICAL
(ITEMNO INT,
NAME VARCHAR2(25),
DESCRIPTION VARCHAR2(25),
QUANTITYINSTOCK INT,
REORDERLEVEL INT,
COSTPERUNIT DECIMAL(6,2),
SUPPLIERNO INT,
CONSTRAINT ITEMNO_NONSURG_PK PRIMARY KEY(ITEMNO));
CREATE TABLE STAFF_CHARGENURSE
(STAFFNO INT,
ADDRESS VARCHAR2(25),
POSITION VARCHAR2(12),
BUDGET DECIMAL(6,2),
SPECIALTY VARCHAR2(12),
CONSTRAINT STAFFNO_CHNURSE_PK PRIMARY KEY(STAFFNO));
CREATE TABLE REQUISITION
(REQNO INT,
STAFFNO INT,
STAFFNAME VARCHAR2(25),
WARDNO INT,
ITEMNO INT,
QUANTITY INT,
DATEORDERED DATE,
DATERECIEVED DATE,
CONSTRAINT REQ_PK PRIMARY KEY(REQNO));
Foreign keys:
ALTER TABLE SUPPLIES_PHARMACEUTICAL
ADD CONSTRAINT SUPPLIERNO_PHA_FK FOREIGN KEY(SUPPLIERNO) REFERENCES SUPPLIER(SUPPLIERNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE SUPPLIES_SURGICAL
ADD CONSTRAINT SUPPLIERNO_SURG_FK FOREIGN KEY(SUPPLIERNO) REFERENCES SUPPLIER(SUPPLIERNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE SUPPLIES_NONSURGICAL
ADD CONSTRAINT SUPPLIERNO_NONSURG_FK FOREIGN KEY(SUPPLIERNO) REFERENCES SUPPLIER(SUPPLIERNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE REQUISITION
ADD CONSTRAINT STAFFNO_REQ_FK FOREIGN KEY(STAFFNO) REFERENCES STAFF_CHARGENURSE(STAFFNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE REQUISITION
ADD CONSTRAINT ITEMNO_PHAR_FK FOREIGN KEY(ITEMNO) REFERENCES SUPPLIES_PHARMACEUTICAL(ITEMNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE REQUISITION
ADD CONSTRAINT ITEMNO_SURG_FK FOREIGN KEY(ITEMNO) REFERENCES SUPPLIES_SURGICAL(ITEMNO)
DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE REQUISITION
ADD CONSTRAINT ITEMNO_NONSURG_FK FOREIGN KEY(ITEMNO) REFERENCES SUPPLIES_NONSURGICAL(ITEMNO)
DEFERRABLE INITIALLY DEFERRED;
Test data:
INSERT INTO REQUISITION VALUES(1, 20, 'Julie Wood', 8, 888520, 2, '27-FEB-2018', '15-MAR-2018');
INSERT INTO REQUISITION VALUES(2, 20, 'Julie Wood', 8, 923956, 1, '25-FEB-2018', '28-FEB-2018');
INSERT INTO REQUISITION VALUES(3, 21, 'Sarah Michaels', 7, 054802, 3, '20-FEB-2018', '22-FEB-2018');
INSERT INTO SUPPLIES_PHARMACEUTICAL VALUES (823456, 100001, 'Zanax', 'Anti Depressant', 8, 2, 100.50, '50mg');
INSERT INTO SUPPLIES_PHARMACEUTICAL VALUES (923956, 100001, 'Zupridol', 'Blood Pressure Treatment', 12, 5, 50, '20mg');
INSERT INTO SUPPLIES_PHARMACEUTICAL VALUES (3952, 200001, 'Amibreezax', 'Artificial Ear Wax', 2, 1, 200, '5g');
INSERT INTO SUPPLIES_PHARMACEUTICAL VALUES (4955, 200001, 'Ambridax', 'Skin Treatment', 5, 10, 20, '2mg');
INSERT INTO SUPPLIES_SURGICAL VALUES (54802, 'Scalpel', 'Surgical Tool', 20, 10, 200.42, 100001);
INSERT INTO SUPPLIES_SURGICAL VALUES (634520, 'Stitches', 'Suture Tool', 100, 10, 2.50, 200001);
INSERT INTO SUPPLIES_NONSURGICAL VALUES (888520, 'Cart', '5ftx2ftx3ft', 2, 0, 200.00, 100001);
INSERT INTO SUPPLIES_NONSURGICAL VALUES (423, 'Tool Holder', 'Holds Inspection Equip.', 4, 2, 50.00, 100001);
INSERT INTO STAFF_CHARGENURSE VALUES(20, '32 Stark St. Portland, OR', 'Charge Nurse', 8000.99, 'Head Trauma');
INSERT INTO STAFF_CHARGENURSE VALUES(21, '18 Wilson Rd Portland, OR', 'Charge Nurse', 6000, 'Epidermus');
INSERT INTO SUPPLIER VALUES (100001,'Company A', '503-222-3333', '100 SE Stark Rd Portland, OR', '503-666-4444');
INSERT INTO SUPPLIER VALUES (200001,'Company B', '666-333-4444', '500 SE Bilerica Rd Akron, OH', '666-444-3333');
COMMIT;
As mentioned in responses to your other related questions, there is no superclass and no subclasses. SUPPLIES_PHARMACEUTICAL, SUPPLIES_SURGICAL and SUPPLIES_NONSURGICAL are just tables with no connection to each other.
All enabled constraints are enforced. Defining them as deferrable just puts off validation until the next commit, which doesn't really change anything in your example. If you define three constraints on a column, there is no syntax or mechanism to say 'only one of these constraints needs to be enforced', and I can't see how such a system would ever be workable.
In data modelling, you define subtypes using either
A single table (e.g. SUPPLIES) with a category or similar indicator column, or
A parent table having just the common columns, and child tables under it having just the type-specific columns, linked back to the parent via foreign key constraints. The child table can have a unique or primary key on the FK column, making it an optional 1:1 relationship.
Other tables can then have FK constraints referencing either the parent or one of its children, as required.
Here's your modified original code (UPPER case original, lower case: modifications), using #William Robertson's ideas: {1} using a single SUPPLIES table, {2} with a is_surgical column, and {3} a pharma_dosage table. Maybe you like it ...
CREATE TABLE SUPPLIER
(SUPPLIERNO integer,
SUPPLIERNAME VARCHAR2(100),
PHONENO VARCHAR2(12),
ADDRESS VARCHAR(100),
FAXNO VARCHAR(12),
CONSTRAINT SUPPLIERNO_SSPL_PK PRIMARY KEY(SUPPLIERNO));
-- one table instead of 3
create table supplies (
ITEMNO integer,
SUPPLIERNO integer,
NAME VARCHAR2(25),
DESCRIPTION VARCHAR2(25),
QUANTITYINSTOCK integer,
REORDERLEVEL integer,
COSTPERUNIT number(6,2),
is_surgical varchar2(1) not null,
constraint supplies_surgical_yn_chk check( is_surgical in ('Y','N') )
, constraint supplies_pk primary key( itemno )
, constraint supplies_fk foreign key( supplierno )
references supplier( supplierno )
);
create table pharma_dosage (
itemno integer
, dosage varchar2( 64 ) not null
, constraint pharma_supplies_fk foreign key( itemno )
references supplies( itemno )
, constraint pharma_supplies_pk primary key( itemno )
);
Two more tables, and - commented out - things we don't need:
-- not needed
-- CREATE TABLE SUPPLIES_PHARMACEUTICAL
-- CREATE TABLE SUPPLIES_SURGICAL
-- CREATE TABLE SUPPLIES_NONSURGICAL
CREATE TABLE STAFF_CHARGENURSE
(STAFFNO integer,
ADDRESS VARCHAR2(25),
POSITION VARCHAR2(12),
BUDGET DECIMAL(6,2),
SPECIALTY VARCHAR2(12),
CONSTRAINT STAFFNO_CHNURSE_PK PRIMARY KEY(STAFFNO));
CREATE TABLE REQUISITION
(REQNO integer,
STAFFNO integer,
STAFFNAME VARCHAR2(25),
WARDNO integer,
ITEMNO integer,
QUANTITY integer,
DATEORDERED DATE,
DATERECIEVED DATE,
CONSTRAINT REQ_PK PRIMARY KEY(REQNO),
constraint req_fk foreign key ( itemno ) references supplies ( itemno )
);
-- not needed
-- ALTER TABLE SUPPLIES_PHARMACEUTICAL ADD CONSTRAINT SUPPLIERNO_PHA_FK
-- ALTER TABLE SUPPLIES_SURGICAL ADD CONSTRAINT SUPPLIERNO_SURG_FK
-- ALTER TABLE SUPPLIES_NONSURGICAL ADD CONSTRAINT SUPPLIERNO_NONSURG_FK
ALTER TABLE REQUISITION ADD CONSTRAINT STAFFNO_REQ_FK
FOREIGN KEY(STAFFNO) REFERENCES STAFF_CHARGENURSE(STAFFNO) DEFERRABLE INITIALLY DEFERRED;
-- not needed
-- ALTER TABLE REQUISITION ADD CONSTRAINT ITEMNO_PHAR_FK
-- ALTER TABLE REQUISITION ADD CONSTRAINT ITEMNO_SURG_FK
-- ALTER TABLE REQUISITION ADD CONSTRAINT ITEMNO_NONSURG_FK
INSERTs
-- parents first
begin
INSERT INTO STAFF_CHARGENURSE VALUES(20, '32 Stark St. Portland, OR', 'Charge Nurse', 8000.99, 'Head Trauma');
INSERT INTO STAFF_CHARGENURSE VALUES(21, '18 Wilson Rd Portland, OR', 'Charge Nurse', 6000, 'Epidermus');
INSERT INTO SUPPLIER VALUES (100001,'Company A', '503-222-3333', '100 SE Stark Rd Portland, OR', '503-666-4444');
INSERT INTO SUPPLIER VALUES (200001,'Company B', '666-333-4444', '500 SE Bilerica Rd Akron, OH', '666-444-3333');
end;
/
PL/SQL procedure successfully completed.
More test data
begin
-- pharmaceutical
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (823456, 100001, 'Zanax', 'Anti Depressant', 8, 2, 100.50, 'N');
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (923956, 100001, 'Zupridol', 'Blood Pressure Treatment', 12, 5, 50, 'N');
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (3952, 200001, 'Amibreezax', 'Artificial Ear Wax', 2, 1, 200, 'N');
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (4955, 200001, 'Ambridax', 'Skin Treatment', 5, 10, 20, 'N');
-- pharma_dosage
insert into pharma_dosage ( itemno, dosage ) values ( 823456, '50mg' ) ;
insert into pharma_dosage ( itemno, dosage ) values ( 923956, '20mg' ) ;
insert into pharma_dosage ( itemno, dosage ) values ( 3952, '5g' ) ;
insert into pharma_dosage ( itemno, dosage ) values ( 4955, '2mg' ) ;
-- surgical
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (54802, 100001, 'Scalpel', 'Surgical Tool', 20, 10, 200.42, 'Y');
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (634520, 200001, 'Stitches', 'Suture Tool', 100, 10, 2.50, 'Y');
-- nonsurgical
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical)
VALUES (888520, 100001, 'Cart', '5ftx2ftx3ft', 2, 0, 200.00, 'N');
INSERT INTO SUPPLIES( itemno, supplierno, name, description, quantityinstock
, reorderlevel, costperunit, is_surgical )
VALUES (423, 100001,'Tool Holder', 'Holds Inspection Equip.', 4, 2, 50.00, 'N');
-- requisition
INSERT INTO REQUISITION VALUES(1, 20, 'Julie Wood', 8, 888520, 2, '27-FEB-2018', '15-MAR-2018');
INSERT INTO REQUISITION VALUES(2, 20, 'Julie Wood', 8, 923956, 1, '25-FEB-2018', '28-FEB-2018');
INSERT INTO REQUISITION VALUES(3, 21, 'Sarah Michaels', 7, 054802, 3, '20-FEB-2018', '22-FEB-2018');
end ;
/
PL/SQL procedure successfully completed.
Now, some SELECTs ...
SQL> select * from supplier ;
SUPPLIERNO SUPPLIERNAME PHONENO ADDRESS FAXNO
100001 Company A 503-222-3333 100 SE Stark Rd Portland, OR 503-666-4444
200001 Company B 666-333-4444 500 SE Bilerica Rd Akron, OH 666-444-3333
SQL> select * from supplies ;
ITEMNO SUPPLIERNO NAME DESCRIPTION QUANTITYINSTOCK REORDERLEVEL COSTPERUNIT IS_SURGICAL
823456 100001 Zanax Anti Depressant 8 2 100.5 N
923956 100001 Zupridol Blood Pressure Treatment 12 5 50 N
3952 200001 Amibreezax Artificial Ear Wax 2 1 200 N
4955 200001 Ambridax Skin Treatment 5 10 20 N
54802 100001 Scalpel Surgical Tool 20 10 200.42 Y
634520 200001 Stitches Suture Tool 100 10 2.5 Y
888520 100001 Cart 5ftx2ftx3ft 2 0 200 N
423 100001 Tool Holder Holds Inspection Equip. 4 2 50 N
SQL> select * from requisition;
REQNO STAFFNO STAFFNAME WARDNO ITEMNO QUANTITY DATEORDERED DATERECIEVED
1 20 Julie Wood 8 888520 2 27-FEB-18 15-MAR-18
2 20 Julie Wood 8 923956 1 25-FEB-18 28-FEB-18
3 21 Sarah Michaels 7 54802 3 20-FEB-18 22-FEB-18
SQL> select * from staff_chargenurse;
STAFFNO ADDRESS POSITION BUDGET SPECIALTY
20 32 Stark St. Portland, OR Charge Nurse 8000.99 Head Trauma
21 18 Wilson Rd Portland, OR Charge Nurse 6000 Epidermus
SQL> select * from pharma_dosage;
ITEMNO DOSAGE
823456 50mg
923956 20mg
3952 5g
4955 2mg
Version 2
If you still want to have one "supertype" and 3 "subtype" tables, have a look at the following DDL. You can probably find a solution that's kind of "in between" the two. (What follows is just "proof of concept" code, several columns and some of the original tables omitted.)
create table supplies (
supplierno number primary key
, category varchar2( 16 )
, constraint unique_parentcategory unique ( supplierno, category )
, constraint check_category check (
category in ( 'surgical', 'non-surgical', 'pharmaceutical' )
)
);
Then ...
create table supplies_pharmaceutical (
supplierno number primary key
, category varchar2( 16 )
--
-- more "specific" columns here
--
, constraint check_category1 check ( category in ( 'pharmaceutical' ) )
, constraint s_p_fk foreign key ( supplierno, category )
references supplies ( supplierno, category )
) ;
create table supplies_nonsurgical (
supplierno number primary key
, category varchar2( 16 )
--
-- more "specific" columns here
--
, constraint check_category2 check ( category in ( 'non-surgical' ) )
, constraint s_n_fk foreign key ( supplierno, category )
references supplies ( supplierno, category )
) ;
create table supplies_surgical (
supplierno number primary key
, category varchar2( 16 )
--
-- more "specific" columns here
--
, constraint check_category3 check ( category in ( 'surgical' ) )
, constraint s_s_fk foreign key ( supplierno, category )
references supplies ( supplierno, category )
) ;
Test data:
begin
insert into supplies( supplierno, category ) values ( 1000, 'pharmaceutical' ) ;
insert into supplies( supplierno, category ) values ( 2000, 'non-surgical' ) ;
insert into supplies( supplierno, category ) values ( 3000, 'surgical' ) ;
insert into supplies_pharmaceutical( supplierno, category )
values ( 1000, 'pharmaceutical' ) ;
insert into supplies_nonsurgical( supplierno, category )
values ( 2000, 'non-surgical' ) ;
insert into supplies_surgical( supplierno, category )
values ( 3000, 'surgical' ) ;
end;
/
-- must fail:
insert into supplies ( supplierno, category ) values ( 1001, 'food' ) ;
insert into supplies_pharmaceutical( supplierno, category )
values ( 2000, 'pharmaceutical' ) ;