Dictionary Tips & Hints

This page contains tips, hints and common gotchas with Dictionary Items.

If you have any you think should be added, please send them to ‘u2tech’ at ‘y7mail.com’.


What are the dictionary item types

There are 4 types of dictionary items in UniData and UniVerse. They are:

  • D-Type: This is a data descriptor
  • I or V-Type: Interpretive descriptor/Virtual field
  • PH: Phrases
  • X-Type: User Defined

D-Type dictionary items point to a single attribute in a record. It is important that you structure your records so that each different type of data can be referenced by a D-Type dictionary item

I or V-Type dictionary items are for calculating or otherwise deriving information from a record. For example, if your record stores the date of birth or a person, you could create an I-Type dictionary item that can grab this information, compare it to the current date and calculate their actual age.

Another common example of I-Type usage is to use a key stored in the record to grab information from another file’s record using the ‘TRANS’ function.

PH-Type dictionary items, or ‘Phases’ contain parts of UniQuery statements, not including the verb (e.g. SELECT, LIST or SORT).

X-Type dictionary items are user defined. After the X in the first attribute, you are free to put whatever you want. This is the ideal place to store any meta-data you may need for the file. One example would be the next available @ID.


How are the PH dictionary items used?

The most common usage is in associations. Sometimes you have a multivalued list of items in one attribute (let’s say first names) that directly correlate to another multivalued list of items in another attribute (let’s say last names). In attribute 7 of your D-Type dictionary record you can specific an ‘association’. In this field you put the @ID of a PH-Type record that lists all the dictionary items that are related. This association comes in handy with the ‘WHEN ASSOCIATED’ clause in a UniQuery statement.

Apart from associations, the PH type dictionary item can be used to change the default query performed with LIST or SORT. You can do this by creating PH-Type dictionaries called @ (UniVerse), @REVISE (UniVerse), @UQ (UniData) and @LPTR (UniData/UniVerse). Normally a ‘LIST FILE’ will just list the @IDs from FILE, but if you put something like ‘LAST.NAME FIRST.NAME BY LAST.NAME’ in the @/@UQ dictionary, it ‘LIST FILE’ will actually do ‘LIST FILE LAST.NAME FIRST.NAME BY LAST.NAME’. @REVISE has exactly the same effect on the REVISE verb in UniVerse and @LPTR has the same effect in UniVerse/UniData when the LIST/SORT output is sent to the printer.

PH type dictionary items can also be used as a shorthand method of using common segments of statements. For example if the often to ‘LIST FILE LAST.NAME FIRST.NAME BY LAST.NAME BY FIRST.NAME’ you could store everything by ‘LIST FILE’ in a PH record SHORT and just run ‘LIST FILE SHORT’. This works in both UniVerse and UniData, but not ECLTYPE P mode in UniData.


Indexing I or V-Type dictionaries

One ‘gotcha’ is when you attempt to create an index, based of a dictionary that references another file or calls a subroutine.

Since the results of these dictionaries may change, without the main file changing, the index will not be updated and result in your queries being incorrect. To correct this, you will need to rebuild your index regularly.

Advice: Don’t index on these type of dictionary items.


UniQuery and the single quote

UniQuery simply cannot handle quote marks in a search string. It takes one look at them and jumps overboard screaming. In most situations this wouldn’t be an issue, but in the times where it is it can be downright annoying.

So, how do you get around this limitation?

One easy method is to create a new I-type dictionary item that removes the single quote from the data. You then have to make sure you strip it out of your search strings (as part of your normal sanitisation routine) then you can successfully search for data that may contain single quotes. Of course, you may need to do some post validation if you require it to exactly match.

Time for an example: In the demo account created by UniData is a file called STUDENT. Add a new student with the last name of “O’Brien”. Try to find this student… LIST STUDENT WITH LNAME = “O’Brien” returns nothing!

So, now to the dictionary item. LNAME is the D-Type dictionary item for the last name and below is the I-Type dictionary item that strips single quotes from it:

Single quote-less I-Type dictionary

Single quote-less I-Type dictionary

Using this new dictionary item instead of LNAME, we can now do a successful search for “OBrien”.

  1. September 1, 2011 at 11:10 am

    I liked your article is an interesting technology
    thanks to google I found you

  2. Elizabeth Justusson
    May 22, 2012 at 8:31 pm

    After the indexing fiasco here the comment I heard was ‘Dan said that indexes only work on the key of the file’. I knew you would not have said that!

    Btw, can’t find anything on it so maybe you can help. The unidata manuals say that you have to compile I-type dictionary items or they will be compiled on execution every time. Does this actually translate to a check for attributes 8 & 9 so if they are already there it assumes the dictionary item has been compiled? Or is it more complicated?

  3. May 23, 2012 at 8:54 am

    Hi Elizabeth. The compiled portion of dictionary items are only used within UniBasic (or UniVerse Basic) programs, such as when you use the ITYPE function.

    • Elizabeth Justusson
      May 25, 2012 at 12:12 am

      According to the manual, “UniData compiles a virtual attribute each time it is executed unless it is compiled in advance by COMPILE.DICT. Compiling in advance may speed execution.”

      So, does this statement apply only to unibasic programs?

      If not then I want to know how UNIDATA knows an item has been compiled.

  4. satya
    June 21, 2012 at 5:06 am

    Thank you Elizabeth for providing valuable information its so helpful

  5. satya
    June 21, 2012 at 5:10 am

    Eligibeth i need a information about the DICT.DICT. Could you please let me know the exact link

  1. February 4, 2012 at 9:03 am

Leave a comment