--
-- Type: TABLE; Owner: I2B2DEMODATA; Name: QT_QUERY_STATUS_TYPE
--
 CREATE TABLE "I2B2DEMODATA"."QT_QUERY_STATUS_TYPE" 
  (	"STATUS_TYPE_ID" NUMBER(3,0) NOT NULL ENABLE, 
"NAME" VARCHAR2(100 BYTE), 
"DESCRIPTION" VARCHAR2(200 BYTE), 
 CONSTRAINT "QT_QUERY_STATUS_TYPE_PKEY" PRIMARY KEY ("STATUS_TYPE_ID")
 USING INDEX
 TABLESPACE "TRANSMART"  ENABLE
  ) SEGMENT CREATION IMMEDIATE
 TABLESPACE "TRANSMART" ;

--
-- Type: SEQUENCE; Owner: I2B2DEMODATA; Name: QT_SQ_QS_QSID
--
CREATE SEQUENCE  "I2B2DEMODATA"."QT_SQ_QS_QSID"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;

--
-- Type: TRIGGER; Owner: I2B2DEMODATA; Name: TRG_QT_QST_ST_ID
--
  CREATE OR REPLACE TRIGGER "I2B2DEMODATA"."TRG_QT_QST_ST_ID" 
   before insert on "I2B2DEMODATA"."QT_QUERY_STATUS_TYPE" 
   for each row 
begin  
   if inserting then 
      if :NEW."STATUS_TYPE_ID" is null then 
         select QT_SQ_QS_QSID.nextval into :NEW."STATUS_TYPE_ID" from dual; 
      end if; 
   end if; 
end;
/
ALTER TRIGGER "I2B2DEMODATA"."TRG_QT_QST_ST_ID" ENABLE;
 
