Monday, May 21, 2007
From the Edge: Using Enhanced CASCADE Options in R:BASE
Section: Enhanced Commands
Chapter: Running R:BASE Your Way!
Platform: R:BASE 7.6 and Turbo V-8 for Windows
Builds: R:BASE 7.6 (7.6.1.30601 or higher ...)
R:BASE C/S:I 7.6 for Windows (Build: 7.6.1.30601 or higher)
R:BASE V-8 Turbo (8.0.15.30601 or higher ...)
The CASCADE option was first introduced in R:BASE 5.5, intended for
global updates or deletes using constraints.
When defining a new table or altering an existing table with PRIMARY
KEY, using the optional CASCADE parameter maintains PRIMARY/FOREIGN
KEY relationships automatically. For example, if you either UPDATE
or DELETE a primary key value from this table, the corresponding
foreign key values are updated or deleted automatically.
The technique of global updates using constraints assumes you are
updating or deleting a PRIMARY KEY value. Using the CASCADE option
you can cascade the change from the PRIMARY KEY to the referenced
FOREIGN KEY columns. Both UPDATE and DELETE options are added once
you add the CASCADE option to your PRIMARY KEY table.
However, using the enhanced options, you may use the traditional
ADD CASCADE option to use both (UPDATE and DELETE) or may use the
ADD CASCADE UPDATE or ADD CASCADE DELETE options selectively.
Traditional CASCADE Options:
CREATE TABLE <TableName> CASCADE
ALTER TABLE <PKtablename> ADD CASCADE
ALTER TABLE <PKtablename> DROP CASCADE
Enhanced CASCADE Options:
CREATE TABLE <tablename> CASCADE UPDATE
CREATE TABLE <tablename> CASCADE DELETE
ALTER TABLE <PKtablename> ADD CASCAD UPDATE
ALTER TABLE <PKtablename> ADD CASCAD UPDATE
Examples:
CREATE TABLE <tablename> CASCADE
CREATE TABLE <tablename> CASCADE UPDATE
CREATE TABLE <tablename> CASCADE DELETE
ALTER TABLE <PKtablename> ADD CASCADE
ALTER TABLE <PKtablename> ADD CASCADE UPDATE
ALTER TABLE <PKtablename> ADD CASCADE DELETE
Use ALTER TABLE <PKtablename> DROP CASCADE to drop cascade flag.
Use LIST CASCADE command to list all cascade flags.
You may use these enhanced options at the command prompt or use the
enhanced Data Designer (RBDEFine) to implement CASCADE to maintain
global updates or deletes using constraints.
When creating a new table at the command prompt, you may use the
following options:
Example 01: Using CASCADE Option (UPDATE and DELETE)
Example 02: Using CASCADE Option (UPDATE only)
Example 03: Using CASCADE Option (DELETE only)
See PDF document for complete details ...
On an existing table with PRIMARY KEY, at the command prompt, you
may use the following options:
Example 01: Using CASCADE Option (UPDATE and DELETE)
ALTER TABLE Customer ADD CASCADE
Example 02: Using CASCADE Option (UPDATE only)
ALTER TABLE Customer ADD CASCADE UPDATE
Example 03: Using CASCADE Option (DELETE only)
ALTER TABLE Customer ADD CASCADE DELETE
See PDF document for complete details ...
When creating a new table using the Data Designer (RBDEFine), you
may use the following options:
Example 01: Using CASCADE Option (UPDATE and DELETE)
Example 02: Using CASCADE Option (UPDATE only)
Example 03: Using CASCADE Option (DELETE only)
A PDF document, with complete details and examples, is available at:
From The Edge: http://www.razzak.com/fte/
Very Best R:egards,
Razzak.
--- RBASE-L
================================================
TO POST A MESSAGE TO ALL MEMBERS:
Send a plain text email to [email protected]
(Don't use any of these words as your Subject:
INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: INTRO
================================================
TO UNSUBSCRIBE:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: UNSUBSCRIBE
================================================
TO SEARCH ARCHIVES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: SEARCH-n
(where n is the number of days). In the message body,
place any
text to search for.
================================================