IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_TASK_MFT')
 CREATE TABLE T_FMM_TASK_MFT (
	FID							BIGINT            DEFAULT 0       NOT NULL,
	FENTRYID					BIGINT            DEFAULT 0       NOT NULL,
	FSEQ						BIGINT            DEFAULT 0       NOT NULL,
	FTRANSCATIONTYPE			BIGINT            DEFAULT 0       NOT NULL,
	FMFTORDERNO					NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FCARDNO						NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FOPERATIONNO			    NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FCARDPROCESS			    NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FPROGROUP					BIGINT            DEFAULT 0       NOT NULL,
	FPROFESSION					BIGINT            DEFAULT 0       NOT NULL,
	FPROGROUPPROCESS			NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FMFTORDERID					NVARCHAR(50)      DEFAULT ' '     NOT NULL,
	FOPERATIONID				NVARCHAR(50)      DEFAULT ' '     NOT NULL
);


EXEC P_ALTERPK 'PK_FMM_TASK_MFT', 'T_FMM_TASK_MFT', 'FENTRYID', '1'; 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_FMM_TASK_MFT_FSEQ') CREATE INDEX IDX_FMM_TASK_MFT_FSEQ ON T_FMM_TASK_MFT ( FID,FSEQ );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_TASK' AND KSQL_COL_NAME ='FPLANAREA') 
  ALTER TABLE T_PMTS_TASK ADD (FPLANAREA BIGINT  DEFAULT 0  NOT NULL);
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_WBS' AND KSQL_COL_NAME ='FPLANTYPE') 
  ALTER TABLE T_PMTS_WBS ADD (FPLANTYPE BIGINT  DEFAULT 0  NOT NULL);
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PMTS_WBS' AND KSQL_COL_NAME ='FPLANAREA') 
  ALTER TABLE T_PMTS_WBS ADD (FPLANAREA BIGINT  DEFAULT 0  NOT NULL);