/**Begin D:\willian\PDM_UPGRADE\PDM1\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ADJUSTRULE') 
 CREATE TABLE T_EB_ADJUSTRULE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FBIZMODEL BIGINT DEFAULT 0 NOT NULL,
FRULECODE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRULENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLTYPE CHAR(1) DEFAULT '0' NOT NULL,
FASSIGNTYPE CHAR(1) DEFAULT '0' NOT NULL,
FUSERID NCLOB DEFAULT ' ',
FUSERNAME NCLOB DEFAULT ' ',
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDATATYPE BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPE BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FRULESTATE CHAR(1) DEFAULT '1' NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ADJUSTRULE_R3') 
 CREATE TABLE T_EB_ADJUSTRULE_R3 (
FID BIGINT DEFAULT 0 NOT NULL,
FREFSTATUS CHAR(1) DEFAULT '0' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ADJUSTRULE_DETAIL') 
 CREATE TABLE T_EB_ADJUSTRULE_DETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDATASET BIGINT DEFAULT 0 NOT NULL,
FENTITY NCLOB DEFAULT ' ',
FADJENTITY NCLOB DEFAULT ' ',
FACCOUNT NCLOB DEFAULT ' ',
FADJACCOUNT NCLOB DEFAULT ' ',
FMETRIC NCLOB DEFAULT ' ',
FADJMETRIC NCLOB DEFAULT ' ',
FCUSTOMDIM1 NCLOB DEFAULT ' ',
FADJCUSTOMDIM1 NCLOB DEFAULT ' ',
FCUSTOMDIM2 NCLOB DEFAULT ' ',
FADJCUSTOMDIM2 NCLOB DEFAULT ' ',
FCUSTOMDIM3 NCLOB DEFAULT ' ',
FADJCUSTOMDIM3 NCLOB DEFAULT ' ',
FCUSTOMDIM4 NCLOB DEFAULT ' ',
FADJCUSTOMDIM4 NCLOB DEFAULT ' ',
FCUSTOMDIM5 NCLOB DEFAULT ' ',
FADJCUSTOMDIM5 NCLOB DEFAULT ' ',
FCUSTOMDIM6 NCLOB DEFAULT ' ',
FADJCUSTOMDIM6 NCLOB DEFAULT ' ',
FCUSTOMDIM7 NCLOB DEFAULT ' ',
FADJCUSTOMDIM7 NCLOB DEFAULT ' ',
FCUSTOMDIM8 NCLOB DEFAULT ' ',
FADJCUSTOMDIM8 NCLOB DEFAULT ' ',
FCUSTOMDIM9 NCLOB DEFAULT ' ',
FADJCUSTOMDIM9 NCLOB DEFAULT ' ',
FCUSTOMDIM10 NCLOB DEFAULT ' ',
FADJCUSTOMDIM10 NCLOB DEFAULT ' ',
FCUSTOMDIM11 NCLOB DEFAULT ' ',
FADJCUSTOMDIM11 NCLOB DEFAULT ' ',
FCUSTOMDIM12 NCLOB DEFAULT ' ',
FADJCUSTOMDIM12 NCLOB DEFAULT ' ',
FCUSTOMDIM13 NCLOB DEFAULT ' ',
FADJCUSTOMDIM13 NCLOB DEFAULT ' ',
FCUSTOMDIM14 NCLOB DEFAULT ' ',
FADJCUSTOMDIM14 NCLOB DEFAULT ' ',
FCUSTOMDIM15 NCLOB DEFAULT ' ',
FADJCUSTOMDIM15 NCLOB DEFAULT ' ',
FCUSTOMDIM16 NCLOB DEFAULT ' ',
FADJCUSTOMDIM16 NCLOB DEFAULT ' ',
FCUSTOMDIM17 NCLOB DEFAULT ' ',
FADJCUSTOMDIM17 NCLOB DEFAULT ' ',
FCUSTOMDIM18 NCLOB DEFAULT ' ',
FADJCUSTOMDIM18 NCLOB DEFAULT ' ',
FCUSTOMDIM19 NCLOB DEFAULT ' ',
FADJCUSTOMDIM19 NCLOB DEFAULT ' ',
FCUSTOMDIM20 NCLOB DEFAULT ' ',
FADJCUSTOMDIM20 NCLOB DEFAULT ' '
);

EXEC P_ALTERPK 'PK_T_EB_ADJUSTRULE', 'T_EB_ADJUSTRULE', 'FID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_ADJUSTRULE') CREATE UNIQUE INDEX IDX_T_EB_ADJUSTRULE ON T_EB_ADJUSTRULE ( FRULECODE );

EXEC P_ALTERPK 'PK_T_EB_ADJUSTRULE_R3', 'T_EB_ADJUSTRULE_R3', 'FID', '1';

EXEC P_ALTERPK 'PK_T_EB_ADJUSTRULE_DETAIL', 'T_EB_ADJUSTRULE_DETAIL', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_EB_ADJUSTRULE_DETAIL') CREATE INDEX IDX_T_EB_ADJUSTRULE_DETAIL ON T_EB_ADJUSTRULE_DETAIL ( FID );

/**End D:\willian\PDM_UPGRADE\PDM1\EB_table.sql **/
