Progress
Language Tutorial
for Character
Deleting Records
The process for deleting records is simple. The following list identifies the steps in the delete process:
Figure 8–15 shows the data movement for the DELETE statement.
Figure 8–15: Data Movement with the DELETE Statement
![]()
The figure may seem nonsensical. The DELETE statement doesn’t copy data to the database. What it does do is mark the record for deletion and release the record to the RDBMS for eventual removal from the database. You could say that DELETE sends instructions, not data, back to the database.
Again, the syntax is simple, although delete has a new useful option. This is the syntax for the DELETE statement.
The VALIDATE function accepts an expression and a message to check and make sure that the deletion is allowable according to your business rules.
Follow these steps for a demonstration of the DELETE statement:
- Open
lt-08-05.p
and run it. The following display appears:
![]()
- Choose the Prev button to get one of the records you created in the last exercise. Since the new records were created with high customer numbers, they appear last in the record list. (Cust-Num is the primary index.)
- Choose Delete Customer. An alert box appears, as shown:
![]()
An alert box is a sophisticated alternative for sending messages to the status area. The status area is an extension of the window widget and so is the alert box.
In event-driven programming, alert boxes ask questions of the user or present the user with important information. Since alert boxes are bearers of important news, they block the rest of the interface—like a dialog box—until the user responds to them.
The reason that a major new component is introduced right in the middle of a discussion on the DELETE statement has to do with good programming style. Good event-driven programming style dictates that you should always have the user confirm deletion of important data with an alert box. "Managing Your Application," discusses how alert boxes work.
- Choose Yes to delete the record, or choose No to cancel the deletion.
If you try to delete one of the records that come with the sports database, you may get alert boxes explaining why you can’t delete the record. These behaviors are established by database triggers in the schema. They are a way of enforcing business rules.
- Choose Exit, then press SPACEBAR to return to the Procedure Editor.
Here is the code that created the display:
These notes help explain the code:
- A special VIEW-AS syntax on a MESSAGE statement reroutes a message from the status area to an alert box. The UPDATE option and variable captures the user’s response to the question.
- If the user answers YES, then the DELETE logic executes.
- This FIND statement upgrades the lock.
- If the record is available with an EXCLUSIVE-LOCK, then DELETE executes.
- Reopening the query rebuilds the results list without the newly deleted record.
- This statement resets the cursor to the first record.
- This logic executes if the record is unavailable for deletion.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |