Submitted by jimspoon on 2018/05/24 01:27
I have been reading the manual section on "smart fields" and am trying to understand it.  www.sqlnotes.net/drupal5/index.php  

It seems that you create a "smart field" the same way that you create a regular field, except you enter text like the following in the Options field for the smart field (in this case, a Text field named "Year"):
 
<source>SELECT ItemID, Format([Date],"yyyy") AS Year FROM ¯qDate;</source>
 
 
Now here is what I am GUESSING is going on here -
 
The SELECT statement generates a table from which acts as the <source> from which the value of the "smart field" "Year" is drawn.  This source table appears to have 2 fields - ItemID, and Year.  IQ looks in this generated table to find an item's ItemID number, and assigns the value in the Year column in that row as the value of the Year smart field for that item.
 
Now ItemID and Date appear to two fields in table called "¯qDate".  ??  I've never seen that "overline" character in front of the "q" before, but I see that it's HEX AF in the ASCII table, and is called the "spacing macron" or "overline".  I don't know if that character and the q have a special meaning in SQL, or whether that is just Pierre's choice for designating a Date table in the database.
 
Do I have this right?   Clarifications or corrections?

 

Comments

This smart fields business got me curious, so I opened the .sndb file from within MS Access.
The table structure of the sample database (I guess any IQ database) is this:
 
It seems that the SQL we are adding in as the Smart Field in the Options part of the Field Management get recorded into the field "Source" in the Fields table. Next screenshot shows the source field for the InfoQube field, but the idea remains the same for the "Smart Fields"
 
 
Although I have next to zero experience with Access and this type of database, from finding all those queries in the navigation under Queries 
made me realize that that q-prefix signifies a query. And the Source field is the SQL statement for that query.
I guess when creating a field, a query "q<FieldName>" is generated with an SQL "SELECT Value AS [FieldName], * From <TypeOfFieldTable> WHERE (FieldID = <AutoGenerated FieldID>.
 
Pierre or other more experienced users may need to validate this though :)

jimspoon

2018/05/26 02:16

In reply to by ethanrox

 Great stuff, Ethanrox!  Thanks for posting that.  Very interesting to get a look "under the hood".

 I vaguely remembered that there was an old posting about what the overscore (¯) meant.
Resurrecting the http://www.sqlnotes.net/drupal5/index.php?q=node/554 file had a 11/18/2007 post:

"The overscore was to group DB related stuff away from the rest (i.e. grids). That way, grids are shown first and are therefore easier to choose (when linking with Office apps).

I also wanted to have a character which is very rarely used to ensure that users wouldn't create fields with that character."

 

(Note that the old 2009 file didn't migrate gracefully, though all the data is there. I'll finish cleaning it up, and post a 2018 update. It has a lot of info that didn't make it into the manual)

 
 
 
 

jimspoon

2018/05/26 02:18

In reply to by KeithB

 Well, how about that!  The overscore was well chosen ... I had never seen this overscore before seeing it on the manual page about Smart Fields.

Excellent Sherlock Holmes !
 
Pierre_Admin
IQ Designer