/**Begin D:\page\rim\pdm\20210723\RIM_table.sql **/
 EXEC p_AlterColumn 'T_RIM_INV_TRANSPORT', 'FCURRENCY', 'NVARCHAR(10)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_RIM_VERIFY' AND KSQL_COL_NAME ='FCUSTOM_CONFIG_TAG') 
 ALTER TABLE T_RIM_VERIFY ADD (FCUSTOM_CONFIG_TAG NCLOB DEFAULT '' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_DOWN_ACCOUNT') 
 CREATE TABLE T_RIM_DOWN_ACCOUNT (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FBATCH_NO VARCHAR(36) DEFAULT ' ' NOT NULL,
FSERIAL_NO VARCHAR(36) DEFAULT ' ' NOT NULL,
FFPY_SERIAL_NO VARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICETYPE BIGINT DEFAULT 0 NOT NULL,
FINVOICE_CODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICE_NO VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FINVOICE_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEFFECTIVE_TAX_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICE_STATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAUTHENTICATE_FLAG VARCHAR(2) DEFAULT ' ' NOT NULL,
FDEDUCTION_PURPOSE VARCHAR(2) DEFAULT ' ' NOT NULL,
FMANAGE_STATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FDATA_TYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSELECT_TIME DATETIME,
FSELECT_AUTHENTICATE_TIME DATETIME,
FSCAN_AUTHENTICATE_TIME DATETIME,
FTAX_PERIOD DATETIME,
FSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_DOWN_INIT') 
 CREATE TABLE T_RIM_DOWN_INIT (
FID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTPUT_DOWNLOAD VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FUSESTATE VARCHAR(2) DEFAULT ' ' NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FTAX_NAME VARCHAR(150) DEFAULT ' ' NOT NULL,
FTAX_NO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBEGIN DATETIME,
FEND DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_DOWN_INPUT') 
 CREATE TABLE T_RIM_DOWN_INPUT (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSERIAL_NO VARCHAR(36) DEFAULT ' ' NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FDATA_TYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FHANDLE_NUM INT DEFAULT 0 NOT NULL,
FSYNC_STATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FERROR_CODE VARCHAR(10) DEFAULT ' ' NOT NULL,
FINVOICE_JSON VARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICE_JSON_TAG NCLOB,
FFPY_SERIAL_NO VARCHAR(36) DEFAULT ' ' NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FINOUT VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VERIFY_DETAIL') 
 CREATE TABLE T_RIM_VERIFY_DETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FVERIFY_NAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FVERIFY_DESCRIPTION VARCHAR(50) DEFAULT ' ' NOT NULL,
FRISK_GRADE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_VERIFY_STATISTIC') 
 CREATE TABLE T_RIM_VERIFY_STATISTIC (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCOMPLIANCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FSERIAL_NO VARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_DOWN_LOG') 
 CREATE TABLE T_RIM_DOWN_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FTASKNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLYDATE DATETIME,
FINVOICETYPE BIGINT DEFAULT 0 NOT NULL,
FINOUT VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSYNC_GOV_STATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FSUCCESS_TOTAL_NUM INT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FTOTAL_NUM INT DEFAULT 0 NOT NULL,
FTAX_NO VARCHAR(30) DEFAULT ' ' NOT NULL,
FSYNC_TYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FBATCH_NO VARCHAR(36) DEFAULT ' ' NOT NULL,
FSYNC_TASK_NO VARCHAR(50) DEFAULT ' ' NOT NULL,
FREQUEST_ID VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLY_STEP INT DEFAULT 0 NOT NULL,
FTAX_BATCH_NO VARCHAR(50) DEFAULT ' ' NOT NULL,
FDOWNLOAD_ERRCODE VARCHAR(10) DEFAULT ' ' NOT NULL
);



/**End D:\page\rim\pdm\20210723\RIM_table.sql **/
