Create the backup table:
CREATE TABLE "CXSINTEGRATION"."IntegrationMapping_Backup"
(
"ObjectID" int NOT NULL,
"IVendID" nvarchar(500) NOT NULL,
"SBOID" int NOT NULL,
"DBName" nvarchar(100) NOT NULL,
PRIMARY KEY ("ObjectID", "SBOID", "DBName")
);
Save the data into backup table:
INSERT INTO "CXSINTEGRATION"."IntegrationMapping_Backup"
(SELECT * FROM "CXSINTEGRATION"."IntegrationMapping");
Create the Store Procedure:
CREATE PROCEDURE "CXSINTEGRATION"."CHNAGETYPE_BIGINT_TO_VARCHAR"()
AS
BEGIN
DECLARE ColumnCount INT:=0;
SELECT COUNT("SCHEMA_NAME") INTO ColumnCount
FROM SYS.COLUMNS
WHERE "COLUMN_NAME"='IVendID' AND "SCHEMA_NAME"='CXSINTEGRATION'
AND "DATA_TYPE_NAME" ='BIGINT';
IF :ColumnCount>0 THEN
CREATE TABLE "CXSINTEGRATION"."IntegrationMapping_New"
(
"ObjectID" int NOT NULL,
"IVendID" nvarchar(500) NOT NULL,
"SBOID" int NOT NULL,
"DBName" nvarchar(100) NOT NULL,
PRIMARY KEY ( "ObjectID" ,"SBOID" ,"DBName")
);
INSERT INTO "CXSINTEGRATION"."IntegrationMapping_New"
(SELECT * FROM "CXSINTEGRATION"."IntegrationMapping");
DROP TABLE "CXSINTEGRATION"."IntegrationMapping";
CREATE TABLE "CXSINTEGRATION"."IntegrationMapping"
(
"ObjectID" int NOT NULL,
"IVendID" nvarchar(500) NOT NULL,
"SBOID" int NOT NULL,
"DBName" nvarchar(100) NOT NULL,
PRIMARY KEY ( "ObjectID", "SBOID", "DBName")
);
INSERT INTO "CXSINTEGRATION"."IntegrationMapping"
(SELECT * FROM "CXSINTEGRATION"."IntegrationMapping_New");
DROP TABLE "CXSINTEGRATION"."IntegrationMapping_New";
END IF;
END;
Execute the Store Procedure:
CALL "CXSINTEGRATION"."CHNAGETYPE_BIGINT_TO_VARCHAR"();