2 Feb 2020

  • February 02, 2020
  • Amitraj
Update Facility

-> Various mechanisms are available for updating information in the database.

-> Creation and deletion of records (via the insert and delete
operations).

-> Modification (via the replace operation) of the content of existing records.




1. Creation of New Records Creation of New Records

->  To insert <record type> into the database, first set the
appropriate values in the corresponding <record type> work-area
template. Then execute

                           insert <record type>
                           where <condition>

-> If the where clause is included, the system searches the
database three (in preorder) for a record that satisfies the
<condition> in the where clause.

-> Once such a record — say, X — is found, the newly created
record is inserted in the tree as the leftmost child of X.

-> If where is omitted, the record is inserted in the first position (in
preorder) in the tree where <record type> can be inserted in
accordance with the specified schema.




2. Modification of an Existing Record Modification of an Existing Record

-> To modify an existing record of type <record type>, we must get
that record into the work-area template for <record type>, and
change the desired fields in that template.

-> Reflect the changes in the database by executing 

                                       replace

-> replace dies not have <record type> as an argument; the record
that is affected is the one to which the currency pointer points.

-> DL/I requires that, prior to a record being modified, the get
command must have the additional clause hold,




3. Deletion of a Record Deletion of a Record

-> To delete a record of type <record type>, set the currency pointer
to point to that record and execute delete.

-> As a record modification, the get command must have the
attribute hold attached to it. Example: Delete account A-561:

                   get hold first account
                   where account.account-number = “A-561”;
                   delete;

-> A delete operation deletes not only the record in question, but
also the entire subtree rooted by that record. Thus, to delete
customer Boyd and all his accounts, we write

                    get gold first customer
                    where customer.customer-name = “Boyd”;

                    delete;

Translate

Popular Posts