/**Begin D:\PDM_UPGRADE\PDM1\TM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TM_REQNOTE' AND KSQL_COL_NAME IN ('FLIMITNO')) 
 ALTER TABLE T_TM_REQNOTE ADD (FLIMITNO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQLIMIT') 
 CREATE TABLE T_TM_REQLIMIT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FVALISTDATE DATETIME,
FVALIENDDATE DATETIME,
FSETSTDATE DATETIME,
FSETENDDATE DATETIME,
FAPPLYLIMIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUSEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMAINAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAPPLYDATE DATETIME,
FREMARK NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQLIMIT_PRD') 
 CREATE TABLE T_TM_REQLIMIT_PRD (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TM_REQLIMIT_L') 
 CREATE TABLE T_TM_REQLIMIT_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(50) DEFAULT ' ' NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\TM_table.sql **/
