Difference between revisions of "ONBEFOREINSERT Table Constraint"

From Lianjapedia
Jump to: navigation, search
(Created page with '==Purpose== Table constraint activated when an attempt is made to insert a new record into the table ==Syntax== ONINSERT <procedure> ONBEFOREINSERT <procedure> ==See Also== [[…')
 
 
Line 18: Line 18:
 
<code lang="recital">
 
<code lang="recital">
 
ALTER TABLE customer;
 
ALTER TABLE customer;
   modify ONINSERT "customer_insert"
+
   modify ONINSERT "customer_oninsert"
 
ALTER TABLE customer;
 
ALTER TABLE customer;
   modify ONBEFOREINSERT "customer_beforeinsert"
+
   modify ONBEFOREINSERT "customer_onbeforeinsert"
 
</code>
 
</code>
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL]]
 
[[Category:SQL]]

Latest revision as of 07:33, 21 November 2012

Purpose

Table constraint activated when an attempt is made to insert a new record into the table

Syntax

ONINSERT <procedure>

ONBEFOREINSERT <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 ONINSERT / ONBEFOREINSERT table constraint is activated when an attempt is made to insert a new record into 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 insert the record is executed and must return True (.T.) or the insert operation is cancelled.

Example

ALTER TABLE customer;
  modify ONINSERT "customer_oninsert"
ALTER TABLE customer;
  modify ONBEFOREINSERT "customer_onbeforeinsert"