Client Interaction¶
This section describes standard mechanisms as to how to create, update or remove records in the server from the client.
Data transport¶
Data transport is handled with the Attribute String. Both the client and the server can pack and unpack an Attribute String.
Server records¶
The server uses records instead of the Attribute Strings. All DML (Data Manipulating Language), create, modify and remove operations in the server are actioned using records. The attribute string is transformed to a server record when the server receives an Attribute String. A server record is defined as:
- record_ <table_name>%ROWTYPE;
This declaration means that all columns in the table exists in the record.
Indicator Records¶
An Indicator Record is a type of server record. This record contains all columns from the table but instead of the actual data it contains a Boolean value if the attribute is changed or not. It should be used internally in the generated server framework methods.
Fetching data¶
The client fetches data from database views using SQL. Many records can be fetched at the same time if needed, for example in an overview form. The attributes objid
and objversion
in a view must be fetched to the client to be able to update or remove a record. These two attributes are used by the server framework for identification, locking and version control.
Manipulating data¶
The actions New__
, Modify__
and Remove__
are used for manipulating data. Please note that these methods have double underscores, and they should not be mixed up with the server methods which have triple underscores. They can be called using action parameters which are set to CHECK or DO. The client normally calls the server, first of all using action CHECK, and then again using action DO. The CHECK action can sometimes be omitted, see Client Information for further information.
Creating a new record¶
A new record is created in this way:
- User press new.
- Fetch the entities default values by calling
New__
method in PREPARE mode.
The server callsPrepare_Insert___
to fetch the default values. - User interaction by adding other values like descriptive attributes and foreign keys.
- User saves the form.
- Client calls
New__
method in CHECK mode.
The server callUnpack___
and unpacks the attribute string into a server record and an indicator record.
The server callCheck_Insert__
and checks that all values in the attribute string are correct. - If CHECK mode does not pass, then a warning message is sent to the client and the following steps will not be performed.
- If CHECK mode passes then the client calls
New__
method in DO mode
The server callsUnpack___
and unpacks the attribute string into a server record and an indicator record.
The server callsCheck_Insert__
and checks that all values in the attribute string are correct.
The server callsInsert___
and creates a new record in the entity. - The server returns
objid
,objversion
and automatic values like server generated attributes and/or server generated primary keys back to the client in the attribute string format. Other information is sent to the client in the Info_ parameter, which can be displayed by the client if required, see Client Information for more information.
Modifying a record¶
Updating a record is done in this way:
- User modifies the record in the client.
- User saves the form.
- Client calls
Modify__
method in CHECK mode.
The server fetches the old record.
The server callsUnpack___
and unpacks the attribute string into a server record and an indicator record.
The server callsCheck_Update__
and checks that all values in the attribute string is correct. - If CHECK mode does not pass, then a warning message is sent to the client and the following steps will not be performed.
- If CHECK mode passes then the client calls
Modify__
method in DO mode.
The server fetches the old record.
The server callsUnpack___
and unpacks the attribute string into a server record and an indicator record.
The server callsCheck_Update__
and checks that all values in the attribute string is correct.
The server callsUpdate___
and updates the entity. - The server returns
objid
,objversion
and automatic values like server generated attributes and/or server generated primary keys back to the client in the attribute string format. Other information is sent to the client in the Info_ parameter, which can be displayed by the client if wanted, see Client Information for more information.
Removing a record¶
Removing a record is done in this way:
- User press delete.
- User saves the form.
- Client calls
Remove__
method in CHECK mode.
The server locks the record.
The server callsCheck_Delete__
and checks that it is valid to remove the record. - If CHECK mode does not pass, then a warning message is sent to the client and the following steps will not be performed.
- If CHECK mode passes then the client calls
Remove__
method in DO mode.
The server locks the record.
The server callsCheck_Delete__
and checks that is is valid to remove the record.
The server callsDelete__
and deletes the record. - Information is sent to the client in the Info_ parameter, which can be displayed by the client if wanted, see Client Information for more information.