/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MAL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER' AND KSQL_COL_NAME IN ('FMALINVTYPE')) 
 ALTER TABLE T_MAL_ORDER ADD (FMALINVTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER' AND KSQL_COL_NAME IN ('FMALPAYTYPE')) 
 ALTER TABLE T_MAL_ORDER ADD (FMALPAYTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_A' AND KSQL_COL_NAME IN ('FASYNCSTATUS')) 
 ALTER TABLE T_MAL_ORDER_A ADD (FASYNCSTATUS CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_SN' AND KSQL_COL_NAME IN ('FMARKID')) 
 ALTER TABLE T_MAL_ORDER_SN ADD (FMARKID NVARCHAR(255) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_JD' AND KSQL_COL_NAME IN ('FINVOICETYPE')) 
 ALTER TABLE T_MAL_ORDER_JD ADD (FINVOICETYPE CHAR(10) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_SN' AND KSQL_COL_NAME IN ('FINVOICETYPE')) 
 ALTER TABLE T_MAL_ORDER_SN ADD (FINVOICETYPE CHAR(10) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MAL_ORDER_SN' AND KSQL_COL_NAME IN ('FINVOICERESULT')) 
 ALTER TABLE T_MAL_ORDER_SN ADD (FINVOICERESULT NVARCHAR(255) DEFAULT ' ' NOT NULL );

 
  EXEC p_AlterColumn 'T_MAL_EMALSTATUS', 'FEMALSTATUSNAME', 'VARCHAR(100)', 'NOT NULL', '0100', ''' ''';

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MAL_table.sql **/
