Feature Rich
Rapid Application Development
Helping you or your customers
Manage their Business

UDB Query Expressions (Simple)

Objects (or records) within Ultimate Database are linked via relationships and these relationships are either Direct or Indirect.

Direct relationships take the form of an ID on one record pointing to another.
So lets use an invoice as an example. This Invoice has a Invoice Number of I-100 and has three item lines on it. So these Invoice Line Objects might then hold the Invoice Number of I-100 directly on these objects. This would probably be stored in "Parent ID A" as the Invoice is a parent of the item line.
These Invoice Line Objects might also hold the ID of the Stock Item being sold. This might be held in "Child ID X" as the Stock Item is a child of the Invoice Line.

Direct relationships are fast and easy to use but they have their limitations. They can only link to one other object and there are a limited number of them for each list (A, X and Y). This is fine for an Invoice line as an Invoice line can only belong to one Invoice and it is only responsible for one Stock Item. If you wanted to link an object to multiple objects such as linking a company to a list of product types that it sold, you would need an indirect relationship.

Indirect relationships Link multiple Object to one another via relationship links. These relationship links are defined on the database and given an ID or Relationship Type ID. So the ID of a Relationship between a Company and it's Products might be 1234.

Queries are simply a way to get from one object to another via a relationship.

UDB uses the Current Object ID as the default starting point in a simple relationship. So if the current object is an Invoice Line and you want to access it Invoice Header that is referred to by the Parent ID A, then the query is simply "A". This could be used in a UDB command to access the Invoice Number {OBJ_DATA(A, 1)}.
If you wanted to access the Stock Item that is referred to by the Child ID X, then the query is "X" or {OBJ_DATA(X, 1)}.

Indirect relationships are used in a very similar manner e.g.{OBJ_DATA(1234, 1)}. The problem is that they may often need to be used in a loop as there may be multiple linked objects to consider. As in the example above, a company might be linked to multiple products. For this, you could use the {FOR_EACH()} command. {FOR_EACH(1234)}{OBJ_DATA(0, 1)}<br />{END_FOR_EACH}. Within the FOR_EACH Loop, the current object (COID) becomes the object you have linked to, so the query is "0", indicating that the data is to be pulled from the current object rather than a related one. This code would display a list of products for the company separated by the HTML line break "<br />".

So the simplest query is effectively just "0", indication the current Object.
You can then have "A", "X", "Y", indicating an object linked to the current object via direct relationships A, X and Y.
There is a full list of these relationship codes below.

Lets say you had Invoice lines linked to the invoice header via direct relationship A, and your current object was the Invoice header and you wanted to access all the Invoice lines that were linked to it. You couldn't simply use "A" as that would refer to the object linked to the Invoice Header via Parent Relationship A.
What you are really asking is "Can I have all Objects in the Invoice Line List (9876) that point to this Invoice Header (the current object) via their Parent A relationship". While that is a bit of a mouth full in English, the simple query equivalent is "A.9876" (Give me everything in list 9876 that points to the current object via relationship A.

List of relationship codes here...