--Order 20014250.130

----------------------------------WORKSTATIONPNLOCK------------------------

CREATE TABLE WORKSTATIONPNLOCK
(
	WORKSTATION_ID       NUMBER NOT NULL ,
	PACKINGNOTE_ID       NUMBER NOT NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
);

ALTER TABLE WORKSTATIONPNLOCK
ADD CONSTRAINT  XPKWORKSTATIONPNLOCK PRIMARY KEY (WORKSTATION_ID);

CREATE UNIQUE INDEX XAK1WORKSTATIONPNLOCK ON WORKSTATIONPNLOCK
(PACKINGNOTE_ID   ASC);

ALTER TABLE WORKSTATIONPNLOCK
ADD CONSTRAINT  XAK1WORKSTATIONPNLOCK UNIQUE (PACKINGNOTE_ID);

ALTER TABLE WORKSTATIONPNLOCK
ADD CONSTRAINT WORKSTATIONPNLOCK_WORKSTATION FOREIGN KEY (WORKSTATION_ID) REFERENCES WORKSTATION (WORKSTATION_ID) ON DELETE CASCADE;

ALTER TABLE WORKSTATIONPNLOCK
ADD CONSTRAINT WORKSTATIONPNLOCK_PACKINGNOTE FOREIGN KEY (PACKINGNOTE_ID) REFERENCES PACKINGNOTE (PACKINGNOTE_ID) ON DELETE CASCADE;
