8. Using Vision Advanced Features : Global Components : Using Record Types
 
Share this page                  
Using Record Types
The data you use in Vision applications generally is in the form of standard Ingres character, numeric, date or money data types. However, you also can combine these data types to create your own data types, called record types.
A record type combines related components of data into a single value. Using a record type increases the efficiency and performance of your application by letting you retrieve, store, or pass multiple data items as a single item.
After you define a record type, you can use it in your application in various ways:
In a local or global variable definition
In a global constant definition
In escape code
As a parameter passed between frames
For example, your application might use a customer table that has four columns—street, city, state and zip code—to store addresses. You can define a record type that combines these four values into a single value. Retrieve the combined customer address into a single local variable and pass its value as a parameter to another frame.
Define a Record Type
To define a record type
1. Select Edit from the menu in the Application Flow Diagram Editor or Visual Query Editor.
Because the record type you define is global to the entire application, you can select any frame as the current frame.
2. Select Global Components from the list of options.
3. Select Record Types from the list of global components.
Vision displays the Edit Application Record Type Definitions window as shown in the following figure:
4. Select Create from the menu.
Vision displays the Create a Record Definition pop-up window as shown in the following figure.
5. Enter a name for the record type.
6. Press Tab.
7. Enter a Short Remark to describe the record type.
This remark appears in the Edit Application Record Type Definitions window. It also appears as a comment in the code that Vision generates for the record type.
8. Select OK from the menu.
Vision displays the Edit a Record Type Definition Window as shown in the following figure. You use this window to specify the various items, or attributes, that make up your record type.
For example, "street" and "city" are two of the four attributes of the "address" record type in the example mentioned above.
9. Select Create from the menu.
Vision displays the Create a Record Attribute pop-up window as shown in the following figure.
10. Enter the name of an attribute and press Tab.
11. Enter a Short Remark to describe this attribute.
12. Specify a data type for the attribute in either of the following ways:
Enter the name of a standard Ingres data type or of another record type that you previously defined.
Use the ListChoices operation.
13. Press Tab.
The cursor moves to the Nullable field. The default value of "yes" indicates that this component can have a null value.
14. Press Tab to accept the default or type no and press to make this component not nullable.
15. Select OK from the menu.
Vision places the attribute definition in the Edit a Record Type Definition window.
16. Repeat Steps 9 through 15 for each attribute of the record type.
17. When you have specified all the attributes for this record type, select End.
Edit a Record Type Definition
You can change the definition of a record type to:
Include additional attributes
Delete attributes
Modify a current attribute to change its data type or nullability
Rename a current attribute
To modify a record type definition
1. Follow Steps 1 through 3 in Define a Record Type.
Vision displays the Edit Application Record Type Definitions window.
2. Position the cursor on the name of the record type.
3. Select Edit from the menu.
Vision displays the Edit a Record Type Definition window.
4. Select the appropriate operation as follows:
To delete an attribute, select Destroy from the menu.
To rename an attribute, select Rename from the menu.
To add new attributes, select Create and follow Steps 10 through 15 in the previous section for defining a record type.
To modify an attribute, select Edit from the menu and enter new values as desired.
5. When finished, select End to return to the Edit Application Record Type Definitions window.
Rename a Record Type
When changing the name of a record type that you have defined, you also must change the name at each place you use the record type throughout the application.
To rename a record type
1. Follow Steps 1 through 3 in Define a Record Type.
Vision displays the Edit Application Record Type Definitions window.
2. Position the cursor on the name of the record type.
3. Select Rename from the menu.
4. When prompted, enter a new name and press Return.
Vision renames the record type.
Destroy a Record Type
When destroying a record type that you have defined, be sure to remove all references to the record type throughout the application; otherwise Vision generates an error when you compile and run the application.
To destroy a record type
1. Follow Steps 1 through 3 in Define a Record Type.
Vision displays the Edit Application Record Type Definitions window.
2. Position the cursor on the name of the record type.
3. Select Destroy from the menu.
Vision asks you to confirm that this is the record type you want to destroy.
4. Enter yes and press Return.
Vision destroys the record type and removes it from the list of record type.