
Executing command: CCMigration_800_810,

--=============================================================================================================================
-- Add Msg Classes and Types relevant for SinumerikNC
--=============================================================================================================================
DECLARE @ID int;
SELECT @ID= MAX(TEXTID) FROM TXTTable
IF @ID IS NULL
	SET @ID = 1
ELSE
	SELECT @ID = @ID+1
 IF NOT EXISTS(SELECT * FROM dbo.MSType WHERE ID = 769)
BEGIN
-- Add 'NC Alarm Type' to text table
INSERT INTO TXTTable (TEXTID) VALUES( @ID );
-- English --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1033' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1033=N''NC Alarm type'' WHERE TEXTID='+@ID);
-- German --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1031' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1031=N''NC-Alarmtyp'' WHERE TEXTID='+@ID);
-- Spanish --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1034' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1034=N''Tipo de alarma NC'' WHERE TEXTID='+@ID);
-- French --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1036' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1036=N''Type d''''alarme NC'' WHERE TEXTID='+@ID);
-- Italian --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1040' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1040=N''Tipo di allarme NC'' WHERE TEXTID='+@ID);

IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1028' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1028=N''NC 警報類型'' WHERE TEXTID='+@ID);
-- Chinese Simplified --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L2052' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L2052=N''NC 报警类型'' WHERE TEXTID='+@ID);
-- Japanese --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1041' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1041=N''NCｱﾗｰﾑﾀｲﾌﾟ'' WHERE TEXTID='+@ID);
-- Korean --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1042' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1042=N''NC 알람 유형'' WHERE TEXTID='+@ID);

 -- Add 'NC Alarm Type' to MSType table
EXEC(N'INSERT INTO dbo.MSType (ID,NAME,COME_TEXTCO,COME_BKCO,GO_TEXTCO,GO_BKCO,QUIT_TEXTCO,QUIT_BKCO,LOCKIT,QUITTYP,HUPE_QUIT,HUPE_VAR,KOMMT,GEHT,KOM_GEHT,QUIT,ACS_ML_NAME,ACS_FN_NAME,CREAT_ID,Short_Name,Priority,Flags) 
VALUES (769,'+@ID+N',0,16777215,0,16777215,0,16777215,0,16,0,0,2,3,4,5,NULL ,NULL, 0,0,0,0)');

IF EXISTS(SELECT * FROM dbo.MSClass WHERE CLASSTYP = 18)
 EXEC (N'UPDATE dbo.MSClass SET TYP_3=275 WHERE CLASSTYP = 18');

 -- Add 'NC Event Type' to text table
SET @ID = @ID+1

INSERT INTO TXTTable (TEXTID) VALUES( @ID );
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1033' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1033=N''NC Event type'' WHERE TEXTID='+@ID);
-- German --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1031' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1031=N''NC-Ereignis Typ'' WHERE TEXTID='+@ID);
-- Spanish --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1034' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1034=N''Tipo de evento NC'' WHERE TEXTID='+@ID);
-- French --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1036' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1036=N''Type d''''événement NC'' WHERE TEXTID='+@ID);
-- Italian --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1040' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1040=N''Tipo di evento NC'' WHERE TEXTID='+@ID);
-- Chinese Traditional --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1028' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1028=N''NC 事件類型'' WHERE TEXTID='+@ID);
-- Chinese Simplified --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L2052' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L2052=N''NC 事件类型'' WHERE TEXTID='+@ID);
-- Japanese --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1041' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1041=N''NCｲﾍﾞﾝﾄﾀｲﾌ'' WHERE TEXTID='+@ID);
-- Korean --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1042' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1042=N''NC 이벤트 유형'' WHERE TEXTID='+@ID);

 -- Add 'NC Event Type' to MSType table
EXEC(N'INSERT INTO dbo.MSType (ID,NAME,COME_TEXTCO,COME_BKCO,GO_TEXTCO,GO_BKCO,QUIT_TEXTCO,QUIT_BKCO,LOCKIT,QUITTYP,HUPE_QUIT,HUPE_VAR,KOMMT,GEHT,KOM_GEHT,QUIT,ACS_ML_NAME,ACS_FN_NAME,CREAT_ID,Short_Name,Priority,Flags) 
VALUES (785,'+@ID+N',0,16777215,0,16777215,0,16777215,0,16,0,0,2,3,4,5,NULL ,NULL, 0,0,0,0)');

-- Add 'NC Alarm Class' to Text table
SET @ID = @ID+1

INSERT INTO TXTTable (TEXTID) VALUES( @ID );
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1033' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1033=N''NC Alarm Class'' WHERE TEXTID='+@ID);
-- German --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1031' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1031=N''NC-Alarmklasse'' WHERE TEXTID='+@ID);
-- Spanish --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1034' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1034=N''Categoría de alarma NC'' WHERE TEXTID='+@ID);
-- French --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1036' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1036=N''Classe d''''alarme NC'' WHERE TEXTID='+@ID);
-- Italian --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1040' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1040=N''Classe di allarme NC'' WHERE TEXTID='+@ID);
-- Chinese Traditional --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1028' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1028=N''NC 警報等級'' WHERE TEXTID='+@ID);
-- Chinese Simplified --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L2052' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L2052=N''NC 报警类别'' WHERE TEXTID='+@ID);
-- Japanese --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1041' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1041=N''NCｱﾗｰﾑｸﾗｽ'' WHERE TEXTID='+@ID);
-- Korean --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1042' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1042=N''NC 알람 클래스'' WHERE TEXTID='+@ID);

 --Add 'NC Alarm Class' to MSClass table
EXEC(N'INSERT INTO dbo.MSClass (NAME,QUITTYP,HUPE_QUIT,HUPE_VAR,KOMMT,GEHT,KOM_GEHT,QUIT,TYP_1,TYP_2,TYP_3,TYP_4,TYP_5,TYP_6,TYP_7,TYP_8,TYP_9,TYP_10,TYP_11,TYP_12,TYP_13,TYP_14,TYP_15,TYP_16,LOCKIT,CLASSTYP,ACS_ML_NAME,ACS_FN_NAME,CREAT_ID,Short_Name)
 VALUES ('+@ID+N',0,0,0,0,0,0,0,769,0,0,0,0,0,0,0 ,0, 0,0,0,0,0,0,0,0,49,NULL,NULL,0,NULL)');

 -- Add 'NC Event Class' to Text table
SET @ID = @ID+1

INSERT INTO TXTTable (TEXTID) VALUES( @ID );
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1033' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1033=N''NC Event Class'' WHERE TEXTID='+@ID);
-- German --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1031' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1031=N''NC-Ereignis Klasse'' WHERE TEXTID='+@ID);
-- Spanish --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1034' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1034=N''Categoría de evento NC'' WHERE TEXTID='+@ID);
-- French --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1036' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1036=N''Classe d''''événement NC'' WHERE TEXTID='+@ID);
-- Italian --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1040' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1040=N''Classe di evento NC'' WHERE TEXTID='+@ID);
-- Chinese Traditional --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1028' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1028=N''NC 事件等級'' WHERE TEXTID='+@ID);
-- Chinese Simplified --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L2052' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L2052=N''NC 事件类别'' WHERE TEXTID='+@ID);
-- Japanese --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1041' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1041=N''NCｲﾍﾞﾝﾄｸﾗｽ'' WHERE TEXTID='+@ID);
-- Korean --
IF EXISTS(SELECT * FROM sys.columns WHERE Name = N'L1042' AND Object_ID = Object_ID(N'dbo.TXTTABLE'))
 EXEC (N'UPDATE TXTTable SET L1042=N''NC 이벤트 클래스'' WHERE TEXTID='+@ID);

 --Add 'NC Event Class' to MSClass table
EXEC(N'INSERT INTO dbo.MSClass (NAME,QUITTYP,HUPE_QUIT,HUPE_VAR,KOMMT,GEHT,KOM_GEHT,QUIT,TYP_1,TYP_2,TYP_3,TYP_4,TYP_5,TYP_6,TYP_7,TYP_8,TYP_9,TYP_10,TYP_11,TYP_12,TYP_13,TYP_14,TYP_15,TYP_16,LOCKIT,CLASSTYP,ACS_ML_NAME,ACS_FN_NAME,CREAT_ID,Short_Name)
 VALUES ('+@ID+N',0,0,0,0,0,0,0,785,0,0,0,0,0,0,0 ,0, 0,0,0,0,0,0,0,0,50,NULL,NULL,0,NULL)');

EXEC (N'UPDATE [dbo].[MCPTCONNECTION] SET NORMDLL=N''CCSinumerikNCNrm.nll'' WHERE PARAMETER LIKE ''%NCAlarm%''');
END

SQL-User Class(14): Violation of PRIMARY KEY constraint 'PK_MSCLASS_CLASSTYP'. Cannot insert duplicate key in object 'dbo.MSClass'. The duplicate key value is (49).
SQL-User Class(14): Violation of PRIMARY KEY constraint 'PK_MSCLASS_CLASSTYP'. Cannot insert duplicate key in object 'dbo.MSClass'. The duplicate key value is (50).
SQL-Info Class(0): The statement has been terminated.
SQL-Info Class(0): The statement has been terminated.
