Currently, there is no UI specific to creating these smart folder-type fields, but users can easily modify existing examples:
Options: <source>SELECT ItemID, [ItemID]>0 AS ItemIsBold
WHERE ((InStr([ItemFont],"|B|")<>0));
*** This used to work, but no longer works now ***
At point 1, we see two items the font of which is in bold. At point 2, we see that there are apparently no items in bold anywhere in the IQbase. Perhaps the way in which the bold type style is stored has changed?
In the next example, we are looking for data that contains the word "Somiro":
Options: <source>SELECT ItemID, [ItemID]>0 AS ProjectSomiro
WHERE ((InStr([Item],"{Somiro}")<>0));
*** This does not work (although I am fairly sure that it used to do so). If you create a grid based on the field ProjectSomiro, it appears to be empty. I have run this example in an IQbase based on the sample data.
Figure 4 Display of a grid based on the field Project Somiro
Interrogating system data in InfoQube
InfoQube functions, in part, because it incorporates what is effectively an active data dictionary. What this means is that the operation of the product depends upon system data which can be accessed by the IQ user by means of SQL queries.
In this example, I have created an SQL query and used it in a grid in which I wish to make a list of all the field names currently in use in a particular IQbase.
Figure 5 shows how I have constructed the necessary SQL statement. Note that it is not clear to me why it is necessary to include an ID field in the query string. I assume that this is necessary because when creating a grid, it is necessary to tie together the field values from different fields. Unfortunately, the documentation on smart fields is silent on this issue. I would like to be able to improve it, but cannot do so without assistance from Pierre.
Figure 5 Building up the necessary SQL in an Excel spreadsheet
Figure 6 shows how I have used the SQL string in the definition of a field called FieldName:
Figure 6 Defining the field in the IQbase Field Properties
Figure 7 shows what happens when a grid is created based on this field. Only one row is returned. The IDitem appears to correspond to a single new item which however does not appear in a grid based on item.
Figure 7 Result: only one row which contains no useful information
Just to prove that smart fields can be made to work, let’s examine this case. I want a list of items which include the word “Gregory” in the text. (Yes, I know there are easier ways of achieving this, but I am just trying to illustrate a point here…).
Note that I have unintelligently based this example on one of the examples that Pierre gives in the standard documentation for the product. Therefore I do not know why it is necessary to include itemID, much less [itemID]>0 - which will always return true, I think. If I now create an eponymous grid (that is to say, a grid with the same name as the field), I get fairly intelligent results (Figure 9):
Figure 9 Results of using the smart field Gregory
The source of this field, that is to say, the data upon which it is based, is a system query called ¯qItem. This is the way in which the InfoQube product actually implements fields; for each field there is a system query whose name is the name of the field preceded by the characters “¯q”. Thus in this case the query is called “¯qItem”.
The examples given by Pierre in the system documentation frequently use underlying InfoQube system data, indicated by the use of the macron character, "¯", Windows key alt +0175. It is unclear to me when it is necessary or advantageous to use system data in this way since it is frequently possible simply to use the name of the field exactly as it normally appears in InfoQube. However, that is not always the case – my earlier example of obtaining a list of field names is an example of where it is essential to use this underlying system data.
Comments
Here is an example which uses only user-level InfoQube fields which I would have thought would work properly but does not. It is based on an existing query which works well. The only change that I have made to the query is to try to refer to another field in the same grid so as to subset the amount of data returned by the SQL SELECT statement. I have tried using a Yes/No (boolean) field called IsCurrent. In the example shown, I am using a text field Current which can take the value Y or N. Adding 'AND IsCurrent' or - as here - 'AND (current = 'Y')' causes the query to break in the way shown in figure 1.
However, for now, it seems probable that the only way forward is for me to ask specific questions on this forum for every question that I have.
Q2: Therefore, the specific question is: why does the example shown not work? How can it be made to work?
Q3: More generally, when is it necessary to have resort to underlying system data and when is it okay to use InfoQube user-level fields?
Q4: Most generally, how does InfoQube work internally? When is it safe and necessary to use underlying system data?
Figure 2 The grid Kind
</edit>
I shall share the IQbase in question with you when I have cleaned it up a little bit! Thank you very much for the kind offer to debug it.
My SQL query does not rename kind as KindVal. KindVal is a drop-down list and is the field which I normally use in grids. I cannot change values in KindVal because I have 'entry must be in list' set for that field. Kind is where I store the data on which the drop-down is based. I have to be able to keep that data up-to-date, and I do that by changing values in the Kind field.
As it happens, you are correct that all values of Kind have a "\" within them. I used the example to show that a complex piece of SQL works. Adding a simple condition, "current = 'Y'", causes it to stop working. In fact, as the following example shows, it seems to be that particular simple condition that causes the SQL to break. What I am trying to achieve with the use of a current field is to restrict the number of values which appear in the drop-down list, which is currently 405 - too high for everyday use.
This brings me back to my original question Q3, which is, what are the rules which govern what is and is not acceptable as an SQL statement? This is what needs to be documented, and perhaps bug-fixed, if this functionality is not to remain something that always requires your specific attention.
[/quote]
As I said in the title of this post, it is quite possible that it is me that is being very stupid. To me, the use of the alias KindVal gives a name to that subset of kind values which meets the WHERE clause.
In use, the semantics associated with the use of this name, KindVal, are very different from those of Kind.
If I click on Kind: I can change values of Kind.
If I click on KindVal: I see a drop-down list from which I can select a value which then stays with the item to which I apply it.
Thus in my original screenshot, there are many items each labelled as '\meta\kind\'. '\meta\kind\' is a class name. An item in the grid Kind can have only one value for KindVal. Thus it is either a '\bird\' or it is a '\plane\' or it is '\Superman\' - but it can only be one of the three.
I have no doubt that the way I have done this is not optimal, but I put it forward as an illustration of what is possible. I have created a field DuplicateItem. In the options for the field I have included:
<source>SELECT ItemID, ItemID > 0, Left([¯fText].[Value],255) AS DuplicateItem
FROM ¯fText
WHERE (((Left([¯fText].[Value],255)) In (SELECT left([¯fText].Value,255) AS DuplicateItem
FROM ¯fText
WHERE ((([¯fText].FieldID)=1))
GROUP BY [¯fText].Value
HAVING (((Count(*))>1))
)))
ORDER BY Left([¯fText].[Value],255);
</source>
I then create an eponymous grid which displays the duplicated items:
For information, I need something like this because my application forbids the creation of duplicate items – items containing the same value. At the present time, InfoQube does not include desirable facilities to set integrity constraints for fields. I would suggest that the product would be much stronger if it were possible to set field-level constraints such as no-duplicates and lookup. Lookup would require the user of a detail field to select a value that already exists in a master field. I suspect that the introduction of this functionality would be fairly straightforward given the way that the product is based upon the use of a relational database.