Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Constraint problem

Author  Topic 

ithrol
Starting Member

1 Post

Posted - 2012-09-07 : 06:27:11
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 :)

Abu-Dina
Posting Yak Master

206 Posts

Posted - 2012-09-07 : 06:33:48
This is a SQL Server forum.

Try posting this in an Oracle forum instead:

http://www.dbforums.com/oracle/
Go to Top of Page
   

- Advertisement -