Links

MSCEWI4055

Default constraint was commented out and may have been added to a table definition.

Severity

Medium

Description

This EWI is added when the default constraint is present in an Alter Table statement.
Currently, there is no support for that constraint. A workaround available to transform it, is when the table is previously defined to the Alter Table, in this way we identify the references, and the default constraint is unified on the table definition; otherwise, the constraint is only commented out.

Code Example

Input Code:

CREATE TABLE table1
(
col1 integer,
col2 varchar collate Latin1_General_CS,
col3 date
);
ALTER TABLE table1
ADD col4 integer,
CONSTRAINT col1_constraint DEFAULT 50 FOR col1,
CONSTRAINT col1_constraint DEFAULT 30 FOR col1;

Output Code:

/*** MSC-WARNING - MSCEWI1069 - USER DEFINED FUNCTION INNER LOGIC WAS TRANSFORMED TO A SINGLE COMMON TABLE EXPRESSION ***/
CREATE OR REPLACE TABLE PUBLIC.table1 (
col1 integer DEFAULT 30,
col2 VARCHAR COLLATE 'EN-CS',
col3 DATE
);
ALTER TABLE PUBLIC.table1
ADD col4 integer,
-- ** MSC-ERROR - MSCEWI4055 DEFAULT MAY HAVE BEEN ADDED TO TABLE DEFINITION **
-- CONSTRAINT col1_constraint DEFAULT 50 FOR col1,
-- ** MSC-ERROR - MSCEWI4055 DEFAULT MAY HAVE BEEN ADDED TO TABLE DEFINITION **
-- CONSTRAINT col1_constraint DEFAULT 30 FOR col1
;
If all the content of the Alter Table is invalid, the Alter Table will be commented out.

Recommendations