-- Oracle
--
-- RCS Revision
--   $Id: attachments.oracle,v 1.1 1999/08/18 23:21:01 shevett Exp $
--
-- Host: localhost    Database: keystone
----------------------------------------------------------

--
-- Table structure for table 'attachments'
--
CREATE SEQUENCE attachments_seq START WITH 1;

CREATE TABLE attachments (
	x_rowid number(10) DEFAULT 0 PRIMARY KEY,
	at_sid number(10) DEFAULT 0 NOT NULL,
	at_fname varchar2(45) DEFAULT '' NOT NULL,
	at_tech varchar2(10),
	at_date number(11),
	at_comment varchar(100)
);

CREATE INDEX attachments_at_sid_idx ON attachments(at_sid);
CREATE INDEX attachments_at_fname_idx ON attachments(at_fname);

CREATE OR REPLACE TRIGGER attachments_trg_bir
BEFORE INSERT ON attachments
FOR EACH ROW
BEGIN
	IF :new.x_rowid IS NULL OR :new.x_rowid = 0
	THEN
		SELECT attachments_seq.nextval INTO :new.x_rowid FROM dual;
	END IF;
END;
/
