To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Using the freetexttable function
Cancel

DataFlex SQL Search

Lesson 1 – Using the freetext function.

  1. In the SQL manager you can see we are using the Chinook search database, in this database there is a full text catalogue that indexes the several fields of the database.
  2. To use this within a query, simply use the FREETEXTFILTER in the ‘where’ class.
    The FREETEXTFILTER is being used to search for body count on the name and composer.
  3. Select all the columns from the track and execute this query.

    The results will show up on the bottom of the screen
  4. In the results you can see that only the tracks that have ‘Body Count’ in the name show up.
  5. If you run it without the filter, it will show all the records.
  6. That is how you use the FREETEXTFILTER in a SQL query.
  7. The next step is to use this FREETEXTFILTER in DataFlex. The simplest way to use FREETEXTFILTER in Dataflex is by setting it as a filter on the data dictionary.
  8. Open the DataFlex Studio and open the chinook search workspace.

  9. In the chinook search workspace there are several views and the one to look at is the SQL full text search view.


  10. Within this view you can see several objects, a DEO structure so the data dictionaries are all available. There is a search form on top and there is a list, which has several columns and these columns are simply data bound. So the track name is bound to the track name database field, it’s a data aware list.
  11. When the user searches, we execute the search function. We’re getting the value from the field and are putting that in a property that we have defined, the ‘psFilterValue’.


  12. We need to use this separate property first and we cannot read the value directly in the data dictionary, because that would cause the filter to be changed on the client side causing synchronization issues.
  13. Here is the ‘OnConstrain’ procedure that constrains the data by setting a ‘psSQLFilter’ and the psSQLFilter is just generated as a string, so here you can see the free text filtering on name and composer.


  14. Percentage 1 is replaced with the filter value. The filter values escape to make sure there is no SQL injection. This is how the list is filtered. Run the example and go to search to get a list with all the data.


  15. Now if you search for ‘body’, you can see that it finds several results.
  16. The language enhancement is in action here to, because it also finds ‘bodies’.