Insert (add a new record)

Top  Previous  Next


Insert, PROC

The Insert method adds a new record to the file, making sure the record is valid, and automatically incrementing key values as required. The Insert method handles any errors that occur while adding the record.

The TryInsert method provides a slightly different (manual) alternative for adding new records.


If Insert succeeds, it returns Level:Benign (declared in ABERROR.INC). If it fails, it returns the severity level of the last error it encountered while trying to add the record. See Error Class for more information on severity levels.

Return Data Type:     BYTE



INCLUDE('ABFILE.INC')                 !declare FileManager class

MAP .                                 !program map

GlobalErrors ErrorClass                !declare GlobalErrors object

Access:Client CLASS(FileManager)       !derive Access:Client object

InsertWindow WINDOW('Add a new Client'),AT(,,159,73),IMM,SYSTEM,GRAY


       ENTRY(@s20),AT(61,20,84,10),USE(CLI:Name),MSG('Client Name'),REQ

       PROMPT('State Code:'),AT(8,34),USE(?CLI:StateCode:Prompt)

       ENTRY(@s2),AT(61,34,40,10),USE(CLI:StateCode),MSG('State Code')


      END CODE

!program code




  IF EVENT() = Event:Accepted               !on OK button

   IF Access:Client.Insert() = Level:Benign !add the new Client record

    POST(Event:CloseWindow)                 !if add succeeds, close down

   ELSE                                     !if add fails

    Access:Client.CancelAutoInc             !restore the file

    CYCLE                                   !and start over



!more code

See Also:     TryInsert, PrimeRecord