Difference between revisions of "ONDELETE Table Constraint"
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Table constraint activated when an attempt is made to delete a record in the table | Table constraint activated when an attempt is made to delete a record in the table | ||
− | |||
==Syntax== | ==Syntax== | ||
ONDELETE <procedure> | ONDELETE <procedure> | ||
+ | ONBEFOREDELETE <procedure> | ||
==See Also== | ==See Also== | ||
[[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]] | [[ALTER TABLE]], [[SQL Constraints|CONSTRAINTS]], [[CREATE TABLE]] | ||
− | |||
==Description== | ==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. | 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 ONDELETE table constraint is activated when an attempt is made to delete a record in the table. The <procedure> specified must be a character expression evaluating to a procedure name. If no file extension is included, '.prg' is assumed. The specified procedure is run before the operation to delete the record is executed and must return True (.T.) or the delete operation is cancelled. | + | The ONDELETE / ONBEFOREDELETE table constraint is activated when an attempt is made to delete a record in the table. The <procedure> specified must be a character expression evaluating to a procedure name. If no file extension is included, '.prg' is assumed. The specified procedure is run before the operation to delete the record is executed and must return True (.T.) or the delete operation is cancelled. |
− | + | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
ALTER TABLE customer; | ALTER TABLE customer; | ||
− | modify ONDELETE " | + | modify ONDELETE "customer_ondelete" |
+ | ALTER TABLE customer; | ||
+ | modify ONBEFOREDELETE "customer_onbeforedelete" | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] |
Latest revision as of 07:24, 21 November 2012
Contents
Purpose
Table constraint activated when an attempt is made to delete a record in the table
Syntax
ONDELETE <procedure>
ONBEFOREDELETE <procedure>
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 ONDELETE / ONBEFOREDELETE table constraint is activated when an attempt is made to delete a record in the table. The <procedure> specified must be a character expression evaluating to a procedure name. If no file extension is included, '.prg' is assumed. The specified procedure is run before the operation to delete the record is executed and must return True (.T.) or the delete operation is cancelled.
Example
ALTER TABLE customer; modify ONDELETE "customer_ondelete" ALTER TABLE customer; modify ONBEFOREDELETE "customer_onbeforedelete"