|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Setting up User-Constraints
Is there any way to set up a User-Defined Constraint to do something like "This integer column cannot be 2 if this row is NULL"
Also, User-Defined Constraints are checked before a record is inserted or updated right? Thanks |
|
#2
|
|||
|
|||
|
Have you looked at using a trigger or handling dml through a stored procedure?
__________________
El éxito consiste en una serie de pequeñas victorias día a día MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html |
|
#3
|
|||
|
|||
|
I only use stored procedures, and I only give my users EXEC access.
I'm going to use triggers to catch it before it gets inserted and updated and do the checking there. Thanks |
|
#4
|
|||
|
|||
|
Easier said then done.
Can someone give me a quick example: I want a trigger that checks a table before it gets inserted or updated. If the value of a column "Status" is >= 3, then [ParentID] cannot be NULL. Is this easy? |
|
#5
|
|||
|
|||
|
I went ahead and used check constraints, because all my constraints apply to a single table.
|
|
#6
|
|||
|
|||
|
You will need to use a BEFORE trigger. This will check the data and rollback if an exception is caught.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Setting up User-Constraints |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|