-- Oracle Table Definition
--
-- RCS Revision
--   $Id: filters.oracle,v 1.1 1999/02/02 17:07:59 roberts Exp $
--

CREATE SEQUENCE filters_seq START WITH 1;

CREATE TABLE filters (
    x_rowid int DEFAULT 0 PRIMARY KEY,
    userid varchar2(20) NOT NULL,
    fdesc varchar2(40),
    ftable varchar2(10) NOT NULL,
    fpublic int,
    fselect varchar2(200)
);

CREATE INDEX filters_userid_idx ON filters(userid);
CREATE INDEX filters_ftable_idx ON filters(ftable);

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