/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BOS_table.sql **/

/** 设置通用语言及添加新字段 **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_PERMITEM' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_PERMITEM ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_PERM_ADMINSCHEME_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PERM_ADMINSCHEME_L', 'FDESCRIPTION', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PERM_ADMINTYPE_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_PERM_CTRLTYPE_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_CTRLTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_CTRLTYPE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_PERM_ROLE_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DATARULES' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_DATARULES ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_DATARULE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_DATARULE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_PERM_DATARULES_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_BIZROLE_L' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_BIZROLE_L ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEGROUP' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_ROLEGROUP ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEGROUP' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_ROLEGROUP ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLEGROUP' AND KSQL_COL_NAME ='FFULLNAME') 
 ALTER TABLE T_PERM_ROLEGROUP ADD (FFULLNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_BIZROLE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_BIZROLE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_BIZROLE' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_BIZROLE ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ADMINTYPE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_ADMINTYPE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ADMINTYPE' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_ADMINTYPE ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_PERM_OPERATIONRULE_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_OPERATIONRULE_L' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_OPERATIONRULE_L ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_OPERATIONRULE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_OPERATIONRULE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_OPERATIONRULE' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_OPERATIONRULE ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ADMINSCHEME' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_ADMINSCHEME ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ADMINSCHEME' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_PERM_ADMINSCHEME ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_PERM_ROLE', 'FREMARK', 'NVARCHAR(255)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PERM_ROLE' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_PERM_ROLE ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );

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