-- FindAlmostEverywhere-Search_LocateQuery.sql
/*
2014-10-23 Tom Holden ve3meo
2014-10-23 rev to include ROWID in LocateQuery
2014-10-24 rev snippet instead of full content

Full text search query on the FTS table "xFTStable" built by the script
 FindAlmostEverywhere-Build_FTS_table.sql from most user-editable text fields
 in the current RootsMagic database. 

It pops up a window for the search term to be entered. This term can be simple 
 or complicated with options described at
 http://www.sqlite.org/fts3.html#section_3. 
It returns the content of the field matching the search which cannot be edited 
so it also returns a SQL query that can be copied into the SQL editor and
executed. That result can be edited. Note that the FTS table will not reflect 
changes until it is rebuilt.

Different search queries can be run without rebuilding the FTS table.

Requires SQLite Expert Personal with unifuzz.dll extension for fake RMNOCASE collation
 or equivalent SQLite manager with support for runtime parameters.

*/

SELECT 
 snippet(xFTStable, '**', '**', '...') AS [snippet]
 , 'SELECT ROWID, '||FieldName||' FROM '||TableName||' WHERE ROWID = '||Rownum||';' AS "LocateQuery" 
FROM xFTStable 
WHERE xFTStable 
MATCH $SearchTerm
;

-- Re-execute as often as needed. SQLite Expert remembers the last $SearchTerm


