#   Commands to prime a standard cascade entry 0 in order to run standalone TestDbi program.

CREATE TABLE DBILOGENTRYVLD(
    SEQNO         INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    TIMESTART     DATETIME NOT NULL,
    TIMEEND       DATETIME NOT NULL,
    DETECTORMASK  TINYINT,
    SIMMASK       TINYINT,
    TASK          INT,
    AGGREGATENO   INT,
    CREATIONDATE  DATETIME NOT NULL,
    INSERTDATE    DATETIME NOT NULL
);

CREATE TABLE DBILOGENTRY(
    SEQNO        INT,
    ROW_COUNTER  INT,
    TABLENAME    TEXT,
    SEQNOMIN     INT NOT NULL,
    SEQNOMAX     INT NOT NULL,
    NUMSEQNO     INT NOT NULL,
    USERNAME     TEXT,
    PROCESSNAME  TEXT,
    HOSTNAME     TEXT,
    SERVERNAME   TEXT,
    LOG_REASON   TEXT
 );

CREATE TABLE DBIDEMODATA1VLD(
    SEQNO         INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    TIMESTART     DATETIME NOT NULL,
    TIMEEND       DATETIME NOT NULL,
    DETECTORMASK  TINYINT,
    SIMMASK       TINYINT,
    TASK          INT,
    AGGREGATENO   INT,
    CREATIONDATE  DATETIME NOT NULL,
    INSERTDATE    DATETIME NOT NULL
);
insert into DBIDEMODATA1VLD values(1,'2001-01-05,10:00:00','2001-01-05,11:00:00',127,127,0,-1,'2001-01-01,01:02:03','2001-03-06,07:02:01');
insert into DBIDEMODATA1VLD values(2,'2001-01-05,13:00:00','2001-01-05,14:00:00',127,127,0,-1,'2001-01-02,01:02:03','2001-03-06,07:05:00');
insert into DBIDEMODATA1VLD values(3,'2000-01-06,10:00:00','2000-01-06,11:00:00',127,127,0,-1,'2001-01-01,01:02:03','2001-03-06,07:02:01');

CREATE TABLE DBIDEMODATA1(
    SEQNO      INT,
    ROW_COUNTER INT,
    SUBSYSTEM  INT,
    PEDESTAL   FLOAT,
    GAIN1      FLOAT,
    GAIN2      FLOAT
 );
insert into DBIDEMODATA1 values(1,1,0,0.90,9.0,90.);
insert into DBIDEMODATA1 values(1,2,1,0.91,9.1,91.);
insert into DBIDEMODATA1 values(1,3,2,0.92,9.2,92.);
insert into DBIDEMODATA1 values(1,4,3,0.93,9.3,93.);
insert into DBIDEMODATA1 values(2,1,0,0.90,9.0,90.);
insert into DBIDEMODATA1 values(2,2,1,0.91,9.1,91.);
insert into DBIDEMODATA1 values(2,3,2,0.92,9.2,92.);
insert into DBIDEMODATA1 values(2,4,3,0.93,9.3,93.);

CREATE TABLE DBIDEMODATA2VLD(
    SEQNO         INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    TIMESTART     DATETIME NOT NULL,
    TIMEEND       DATETIME NOT NULL,
    DETECTORMASK  TINYINT,
    SIMMASK       TINYINT,
    TASK          INT,
    AGGREGATENO   INT,
    CREATIONDATE  DATETIME NOT NULL,
    INSERTDATE    DATETIME NOT NULL
);

CREATE TABLE DBIDEMODATA2(
    SEQNO      INT,
    ROW_COUNTER  INT,
    AGGREGATENO   INT,
    SUBSYSTEM  INT,
    DATA       FLOAT
);


CREATE TABLE DBIDEMODATA4VLD(
    SEQNO         INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    TIMESTART     DATETIME NOT NULL,
    TIMEEND       DATETIME NOT NULL,
    DETECTORMASK  TINYINT,
    SIMMASK       TINYINT,
    TASK          INT,
    AGGREGATENO   INT,
    CREATIONDATE  DATETIME NOT NULL,
    INSERTDATE    DATETIME NOT NULL 
);

CREATE TABLE DBIDEMODATA4(
    SEQNO        INT,
    ROW_COUNTER  INT,
    SOFTW_NAME   TEXT,
    CONFIG_NAME  TEXT,
    CONFIG_DATA  TEXT
);   

CREATE TABLE LOCALSEQNO(
    TABLENAME      CHAR(64) NOT NULL PRIMARY KEY,
    LASTUSEDSEQNO  INT );
INSERT INTO LOCALSEQNO VALUES ('*',0);
INSERT INTO LOCALSEQNO VALUES ('DBIDEMODATA1',3);

CREATE TABLE GLOBALSEQNO(
    TABLENAME      CHAR(64) NOT NULL PRIMARY KEY,
    LASTUSEDSEQNO  INT );
INSERT INTO GLOBALSEQNO VALUES ('*',900000000);

CREATE TABLE ALL_DATA_TYPESVLD(
    SEQNO         INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    TIMESTART     DATETIME NOT NULL,
    TIMEEND       DATETIME NOT NULL,
    DETECTORMASK  TINYINT,
    SIMMASK       TINYINT,
    TASK          INT,
    AGGREGATENO   INT,
    CREATIONDATE  DATETIME NOT NULL,
    INSERTDATE    DATETIME NOT NULL
);

INSERT INTO ALL_DATA_TYPESVLD VALUES(
  990000000,'2005-01-01 00:00:00','2006-01-01 00:00:00',
  127,127,0,-1,
  '2005-01-01 00:00:00','2005-01-01 00:00:00'
);

CREATE TABLE ALL_DATA_TYPES(
    SEQNO            INT,
    MY_TINYINT       TINYINT,
    MY_SMALLINT      SMALLINT,
    MY_INT           INT,
    MY_BIGINT        BIGINT,
    MY_FLOAT         FLOAT,
    MY_DOUBLE        DOUBLE,
    MY_TINYTEXT      TINYTEXT,
    MY_TEXT          TEXT,
    MY_CHAR          CHAR,
    MY_CHARS_2       CHAR(2),
    MY_CHARS_3       CHAR(3),
    MY_CHARS_4       CHAR(4),
    MY_CHARS_5       CHAR(5),
    MY_CHARS_6       CHAR(6),
    MY_CHARS_20      CHAR(20),
    MY_DATETIME      DATETIME );

INSERT INTO ALL_DATA_TYPES VALUES(
    990000000,
    123,
    12345,
    123456789,
    1234567890123456789,
    1.234567890,
    2.345678901234567890,
    'abc',
    'abcdefghijklmnopqrstuvwxyz',
    'a',
    'ab',
    'abc',
    'abcd',
    'abcde',
    'abcdef',
    'aaaaaaaaaabbbbbbbbbb',
    '2005-02-02 01:02:03'
);
