Difference between revisions of "CHECK Table Constraint"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Table constraint activated when an operation to insert, update or delete records in the table is called | Table constraint activated when an operation to insert, update or delete records in the table is called | ||
Line 21: | Line 14: | ||
A constraint is used to define rules that help to provide data integrity. TABLE constraints apply to table-based operations. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation. | A constraint is used to define rules that help to provide data integrity. TABLE constraints apply to table-based operations. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation. | ||
− | The CHECK table constraint is activated when an operation to insert, update or delete records in the table is called. The <condition> specified must evaluate to True (.T.) for the operation to succeed. If the <condition> evaluates to False (.F.) the operation is abandoned and the ERROR table constraint message is displayed. If the ERROR table constraint has not been defined, a default error message is displayed. | + | The CHECK table constraint is activated when an operation to insert, update or delete records in the table is called. The <condition> specified must evaluate to True (.T.) for the operation to succeed. If the <condition> evaluates to False (.F.) the operation is abandoned and the [[ERROR_Table_Constraint|ERROR]] table constraint message is displayed. If the [[ERROR_Table_Constraint|ERROR]] table constraint has not been defined, a default error message is displayed. |
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | CREATE TABLE purchase_order; | |
− | CREATE TABLE purchase_order (POid i PRIMARY KEY, SuppId i, POtotal n(10,2), ; | + | (POid i PRIMARY KEY, SuppId i, POtotal n(10,2),; |
− | CHECK callauth() ERROR | + | CHECK callauth(); |
+ | ERROR "Not authorized") | ||
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital, Recital Server |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] |
Latest revision as of 10:33, 22 December 2009
Purpose
Table constraint activated when an operation to insert, update or delete records in the table is called
Syntax
CHECK <condition>
See Also
ALTER TABLE, CONSTRAINTS, CREATE TABLE
Description
A constraint is used to define rules that help to provide data integrity. TABLE constraints apply to table-based operations. You must have ALTER privilege on the table. The table will be locked for EXCLUSIVE use during the operation.
The CHECK table constraint is activated when an operation to insert, update or delete records in the table is called. The <condition> specified must evaluate to True (.T.) for the operation to succeed. If the <condition> evaluates to False (.F.) the operation is abandoned and the ERROR table constraint message is displayed. If the ERROR table constraint has not been defined, a default error message is displayed.
Example
CREATE TABLE purchase_order; (POid i PRIMARY KEY, SuppId i, POtotal n(10,2),; CHECK callauth(); ERROR "Not authorized")
Products
Recital, Recital Server