/**BEGIN D:\PDM_UPGRADE\PDM1\EB_CONSTRAINT.SQL **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVE_AUDITOR') 
CREATE TABLE T_EB_APPROVE_AUDITOR(
    FID              BIGINT                                     NOT NULL,
    FENTRYID         BIGINT                                     NOT NULL,
    FSEQ             INTEGER     DEFAULT 0                      NOT NULL,
    FCREATOR         BIGINT,
    FCREATEDATE      DATETIME,
    FMODIFIER        BIGINT,
    FMODIFYDATE      DATETIME,
    FAUDITORTYPE     VARCHAR(50) DEFAULT ' ',
    FAUDITORRANGE    VARCHAR(50) DEFAULT ' ',
    FAUDITOR         BIGINT,
    FBILLORGKEY      VARCHAR(50) DEFAULT ' ',
    FRELATIONTYPE    VARCHAR(50) DEFAULT ' ',
    FAUDITORFIELDKEY VARCHAR(50) DEFAULT ' ',
    FPERSON          BIGINT,
    FREFERENCEPERSON VARCHAR(50) DEFAULT ' ',
    FRELATION        BIGINT,
    FWFROLE          BIGINT
);

EXEC P_ALTERPK 'PK_EB_APPROVE_AUDITOR', 'T_EB_APPROVE_AUDITOR', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVE_CENTRALIZED') 
CREATE TABLE T_EB_APPROVE_CENTRALIZED(
    FID                BIGINT            NOT NULL,
    FENTRYID           BIGINT            NOT NULL,
    FSEQ               INTEGER DEFAULT 0 NOT NULL,
    FCENTRALIZEDSCHEME BIGINT,
    FCREATOR           BIGINT,
    FCREATEDATE        DATETIME,
    FMODIFIER          BIGINT,
    FMODIFYDATE        DATETIME
);
EXEC P_ALTERPK 'PK_EB_APPROVE_CENTRALIZED', 'T_EB_APPROVE_CENTRALIZED', 'FENTRYID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVE_ADJDIM') 
CREATE TABLE T_EB_APPROVE_ADJDIM(
    FID                BIGINT                                     NOT NULL,
    FENTRYID           BIGINT                                     NOT NULL,
    FSEQ               INTEGER     DEFAULT 0                      NOT NULL,
    FDIMENSION         VARCHAR(50) DEFAULT ' ',
    FDIMMEMLEVEL       VARCHAR(50) DEFAULT ' ',
    FCREATOR           BIGINT,
    FCREATEDATE        DATETIME,
    FMODIFIER          BIGINT,
    FMODIFYDATE        DATETIME,
    FDIMENSIONNUM      VARCHAR(50) DEFAULT ' ',
    FDIMENSIONID       BIGINT,
    FRANGETYPE         VARCHAR(50) DEFAULT ' ',
    FORGREFERENCEFIELD VARCHAR(50) DEFAULT ' ',
    FBASEDATAID        VARCHAR(50) DEFAULT ' ',
    FDIMTYPE           VARCHAR(50) DEFAULT ' ',
    FROWID             VARCHAR(50) DEFAULT ' '
);
EXEC P_ALTERPK 'PK_EB_APPROVE_ADJDIM', 'T_EB_APPROVE_ADJDIM', 'FENTRYID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVE_ADJDIMCOPY') 
CREATE TABLE T_EB_APPROVE_ADJDIMCOPY
(
	FID BIGINT NOT NULL,
	FENTRYID BIGINT NOT NULL,
	FSEQ INTEGER DEFAULT 0 NOT NULL,
	FDIMENSION VARCHAR(50) DEFAULT ' ',
	FDIMMEMLEVEL VARCHAR(50) DEFAULT ' ',
	FDIMENSIONNUM VARCHAR(50) DEFAULT ' ',
	FDIMENSIONID BIGINT,
	FCREATOR BIGINT,
	FCREATEDATE DATETIME,
	FMODIFIER BIGINT,
	FMODIFYDATE DATETIME,
	FRANGETYPE VARCHAR(50) DEFAULT ' ',
	FDIMTYPE VARCHAR(50) DEFAULT ' ',
	FBASEDATAID VARCHAR(50) DEFAULT ' ',
	FDIMMEMBERID VARCHAR(50) DEFAULT ' ',
	FORGREFERENCEFIELD VARCHAR(50) DEFAULT ' ',
	FROWID VARCHAR(50) DEFAULT ' '
);
EXEC P_ALTERPK 'PK_EB_APPROVE_ADJDIMCOPY', 'T_EB_APPROVE_ADJDIMCOPY', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ADJDIMMEMBER') 
CREATE TABLE T_EB_ADJDIMMEMBER
(
	FID BIGINT NOT NULL,
	FENTRYID BIGINT NOT NULL,
	FSEQ INTEGER DEFAULT 0 NOT NULL,
	FBASEDATATYPE VARCHAR(50) DEFAULT ' ',
	FMEMBERID BIGINT,
	FRELATIONROWID VARCHAR(50) DEFAULT ' '
);
EXEC P_ALTERPK 'PK_EB_ADJDIMMEMBER', 'T_EB_ADJDIMMEMBER', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ADJDIMMEMBER_COPY') 
CREATE TABLE T_EB_ADJDIMMEMBER_COPY
(
	FID BIGINT NOT NULL,
	FENTRYID BIGINT NOT NULL,
	FSEQ INTEGER DEFAULT 0 NOT NULL,
	FMEMBERID BIGINT,
	FBASEDATATYPE VARCHAR(50) DEFAULT ' ',
	FRELATIONROWID VARCHAR(50) DEFAULT ' '
);
EXEC P_ALTERPK 'PK_EB_ADJDIMMEMBER_COPY', 'T_EB_ADJDIMMEMBER_COPY', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVE_ADJDIMPLAN') 
CREATE TABLE T_EB_APPROVE_ADJDIMPLAN(
	FID BIGINT NOT NULL,
	FENTRYID BIGINT NOT NULL,
	FSEQ INTEGER DEFAULT 0 NOT NULL,
	FNAME VARCHAR(50) DEFAULT ' ',
	FNUMBER VARCHAR(50) DEFAULT ' ',
	FCREATOR BIGINT,
	FCREATEDATE DATETIME,
	FMODIFIER BIGINT,
	FMODIFYDATE DATETIME
);
EXEC P_ALTERPK 'PK_EB_APPROVE_ADJDIMPLAN', 'T_EB_APPROVE_ADJDIMPLAN', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALADJSCHEME') 
CREATE TABLE T_EB_CENTRALADJSCHEME(
	FID BIGINT NOT NULL,
	FNAME VARCHAR(75) DEFAULT ' ' NOT NULL,
	FNUMBER VARCHAR(75) DEFAULT ' ' NOT NULL,
	FCREATOR BIGINT,
	FCREATEDATE DATETIME,
	FMODIFIER BIGINT,
	FMODIFYDATEFIELD DATETIME,
	FBUSINESSMODELID BIGINT,
	FMODELID BIGINT,
	FMAINMODIFYDATE DATETIME
);
EXEC P_ALTERPK 'PK_EB_CENTRALADJSCHEME', 'T_EB_CENTRALADJSCHEME', 'FID', '1';

