INSERT Statement

Adds new records, groups, or items to an existing access descriptor.

Type: Optional statement
Applies to: access descriptor
Interaction: UPDATE statement

Syntax

INSERT | INS index-number;
INSERT | INS item-name <... item-name-n> ;

Optional Arguments

item-number

is an index number that represents the item's place in the access descriptor. You can get the index number of an item by using the LIST statement described later in this section.

item-name

is the name of the IMS group, record, or item after which subsequent groups, records, or items are inserted. This field can also contain a quoted string.

Details

The INSERT statement is a positioning statement; it inserts the RECORD=, GROUP=, or ITEM= statements following it after the item that it references. The syntax and use of the RECORD=, GROUP=, and ITEM= statements are the same in Update mode as they are in Create mode.
Although the INSERT statement can reference only one item, more than one RECORD=, GROUP=, or ITEM= statement can follow an INSERT statement. The INSERT statement retains control until it encounters an editing, LIST, DELETE, or REPLACE statement, or the ACCESS procedure ends through a QUIT, RUN, or other procedure statement. Multiple INSERT statements can be used in one UPDATE statement. When more than one INSERT statement references the same item, the most recent update displays as first.
The following is an example of an INSERT statement. A new record and item are inserted at the beginning of the access descriptor ADLIB.CUSTINS. “INSERT 0” inserts items at the beginning of the descriptor. The first item in an access descriptor must always be a record. Also in the example, note that the first LIST statement prints a pre-update listing of the database as defined by the access descriptor, while the second prints a post-update listing.
proc access dbms=ims;
   update adlib.custins.access;
      list all db;
      insert 0;
        record=newfrec sg=newrecsg sl=400;
        item=newfitem lv=3 dbf=$12. se=custfsti;
      list all db;
run;