After sending a small test project to Rubicon and getting a similar test back i think i understand what is going on.
The original “bug” description went:
When i assign event handlers to the TextLinks OnMaxIndex and OnMinIndex and run rbMake.Execute i get an exception from the RDBMS saying “empty statements are not allowed”. But when i refrain from assigning those events, the rbMake.Execute works fine.
OK, i think i know whats going on and what might be my (huge) misunderstanding.
This is all about rbMake (no other component).
When rbMake works (unassigned events)
The engine executes the queries to get min and max.
-
SELECT MAX(ID) AS MAXINDEX FROM DOCUMENTS
-
SELECT ID, SEARCH_META_TEXT, SEARCH_CONTENT_TEXT FROM DOCUMENTS WHERE ID = :Location
-
SELECT MIN(ID) AS MININDEX FROM DOCUMENTS
-
SELECT ID, SEARCH_META_TEXT, SEARCH_CONTENT_TEXT FROM DOCUMENTS WHERE ID = :Location
(I assume 2 and 4 is for checking that i provided the correct values.)
Then the engine creates the “main” query, i.e. the one that fetches rows with text to index:
SELECT ID, SEARCH_META_TEXT, SEARCH_CONTENT_TEXT
FROM DOCUMENTS
WHERE (ID > :Lowest) AND (ID <= :Highest) ORDER BY ID
When rmMake failes (assigned event) - in MY project
The engine skips the queries for checking out min and max (of course, that is the idea) and goes immediately to open the FDQueryText cursor.
So in TrbTextDataSetLink.Open (called from TrbCustomMake.Execute) the FDQueryText is activated.
- In my dfm the query is empty - i get an exception.
- In Rubicon dfm there is a query, it is activated (not fetched though).
But this activation is useless IMHO because then the engine creates the correct SQL including the WHERE clause.
Now i would like to know, Lajos (who sent the Rubicon test project), did you manually put the SQL in the dfm?
This is the SQL that is present in your projects dfm but not in mine:
SELECT ID, SEARCH_CONTENT_TEXT, SEARCH_META_TEXT FROM DOCUMENTS
ORDER BY ID
This is the query that is actually fetched (it is generated, or it might be parsed from the dfm SQL):
SELECT ID, SEARCH_CONTENT_TEXT, SEARCH_META_TEXT
FROM DOCUMENTS
WHERE (ID > :Lowest) AND (ID <= :Highest) ORDER BY ID
Same as above.
If the FDQueryText.SQL property is cleared, you will get the same error as i get, the RDBMS complains about an empty statement.
What i cannot fathom; in essence why i have been so confused about this:
- using Min/Max events a query is needed in the FDQueryText before calling rbMake.
- using Rubicons own code (unassigned events) the same SQL is 100% automatically created.
IMHO this is a discrepancy (i hope i chose the right word) that is very confusing. When starting the compiled demo (or if it was the few i could compile) i remember the SQL had “Do not set Rubicon will create the SQL for you” or similar.
In order to see the difference in the Rubicon test project, assign an event handler to the TextLinks FDQuerys OnCommandChanged and display the SQL.Text in a memo or similar.
To add to this in the Rubicon project you have selected “ID” in the fields editor. Why? Before you call rbMake you must reinit the FieldNames to remove the ID field or you will get “ambigious column name” exception or similar.
First off, in my Delphi 11 the checkboxes are so small, i thought the property editor it did not work. It does
My eyesight is bad
/D