SolveErrors
Microsoft SQL Server

Constraint problem

15 views

Ok so im running into some issues executing my code.
So creating the table

CREATE TABLE Penalty(
Penalty_Type CHAR(8),
MinDay NUMERIC(3,0) NOT NULL,
MaxDay NUMERIC(3,0) NOT NULL,
"Cost" NUMERIC(3,2) NOT NULL,
CONSTRAINT Penalty_PenaltyType_pk PRIMARY KEY(Penalty_Type),
CONSTRAINT Penalty_PenaltyType_ck CHECK(Penalty_Type LIKE '[P][e][n][a][l][t][y][0-9]')
);

Then inserting the data

INSERT ALL
INTO Insurance VALUES ('N','No Cover',0)
INTO Insurance VALUES ('P', 'Partial Cover', 20.99)
INTO Insurance VALUES ('F', 'Full Cover', 35.5)
SELECT * FROM dual;

Then getting this error message,

SQL Error: ORA-02290: check constraint (SYSTEM.INSURANCE_INSURANCEID_CK) violated
02290. 00000 - "check constraint (%s.%s) violated"
*Cause: The values being inserted do not satisfy the named check

*Action: do not insert values that violate the constraint.

then i remove the constraint and i get this one, i cant seem to win :(

SQL Error: ORA-01438: value larger than specified precision allowed for this column
01438. 00000 - "value larger than specified precision allowed for this column"
*Cause: When inserting or updating records, a numeric value was entered
that exceeded the precision defined for the column.
*Action: Enter a value that complies with the numeric column's precision,
or use the MODIFY option with the ALTER TABLE command to expand
the precision.

any help greatly appreciated :)

More Microsoft SQL Server fixes

selectcommand and tiny int datatypeQuery issue in file with .htaccess entryESt to ISTNew to Reporting PackagesCould not find stored procedure 'sp_filestream_configure'.Condensing Multiple Update Statements