/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AP_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCERANGE')
 CREATE TABLE T_AP_TOLERANCERANGE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMENSIONPK2 NCLOB,
FDIMENSIONPK3 NCLOB,
FDIMENSIONPK4 NCLOB,
FDIMENSIONPK5 NCLOB,
FDIMENSIONPK6 NCLOB,
FDIMENSIONPK7 NCLOB,
FDIMENSIONPK8 NCLOB,
FDIMENSIONPK9 NCLOB,
FDIMENSIONPK1 NCLOB,
FDIMENSIONPK10 NCLOB,
FLIMITTOLERANCE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUPTOLERANCE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCERULEENTRY')
 CREATE TABLE T_AP_TOLERANCERULEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FTOLERANCETYPEID BIGINT DEFAULT 0 NOT NULL,
FISPREINSERT CHAR(1) DEFAULT ' ' NOT NULL,
FTOLERANCEDIM VARCHAR(100) DEFAULT ' ' NOT NULL,
FLIMITTOLERANCETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FUPTOLERANCETYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FDIMENSIONMAP NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCESCHEME')
 CREATE TABLE T_AP_TOLERANCESCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCONTROLLER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCONTRASTER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDESCRIBE NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCESCHEME_L')
 CREATE TABLE T_AP_TOLERANCESCHEME_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCETYPE')
 CREATE TABLE T_AP_TOLERANCETYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCONTROLLER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCONTRASTER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCONTROLITEM VARCHAR(30) DEFAULT ' ' NOT NULL,
FCONTRASTITEM VARCHAR(30) DEFAULT ' ' NOT NULL,
FISPREINSERT CHAR(1) DEFAULT ' ' NOT NULL,
FCONTROLITEMNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCONTRASTITEMNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDESCRIBE NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AP_TOLERANCETYPE_L')
 CREATE TABLE T_AP_TOLERANCETYPE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);