Code: Select all
on mouseUp  --foreign key choices  **works**
   local tID, tSQL, tFKData, tData, tFldNames
   put the cDatabaseID of this stack into tID
   --PRAGMA foreign_key_list():  --item3=table referenced, item4=foreign key field
   put "PRAGMA foreign_key_list(" "e& the label of btn "Tables" "e& ");" into tSQL
   put revDataFromQuery(comma,cr,tID,tSQL) into tFKData
   if item 1 of tFKData = "revdberr" then ErrorTest tFKData  --in stack
   ----
    --PRAGMA table_info(): number,name,fieldtype,notnull=1,defaultvalue,primkey=1
   put "PRAGMA table_info(" "e& item 3 of tFKData "e& ");" into tSQL  --table referenced
   put revDataFromQuery(comma,cr,tID,tSQL) into tData
   if item 1 of tData = "revdberr" then ErrorTest tData
   repeat for each line i in tData  --comma list of fld names
      put quote& item 2 of i "e&"," after tFldNames
      if number(items in tFldNames) = "3" then exit repeat  --only first 3 columns
   end repeat
   delete char -1 of tFldNames  --last comma
   ----
   put "SELECT" && tFldNames&& "FROM" &"e& item 3 of tFKData "e& ";" into tSQL  --select first 3 columns table referenced
   put revDataFromQuery(comma,cr,tID,tSQL) into tData
   if item 1 of tData = "revdberr" then ErrorTest tData
   ----
   set the text of btn "PopUp" to tData  --referenced table records
   set the topRight of btn "PopUp" to the topRight of fld 2 of grp (item 4 of tFKData)  --foreign key field
   set the layer of btn "PopUp" to "top"  --bring to front
   show btn "PopUp"  --visible
end mouseUp
and MaxV's stack "SQLite Browser" ( http://livecodeshare.runrev.com/stack/7 ... administer )
were very helpful making my program, thank you.
These SQLite links were also helpful:
https://sqlite.org/lang.html --SQLite Syntax
https://sqlite.org/datatype3.html --SQLite Data Types
https://sqlite.org/foreignkeys.html --SQLite Foreign Keys
https://www.sqlite.org/faq.html --SQLite FAQ
SQLite FAQ #22: Does SQLite support foreign keys? As of version 3.6.19 (2009-10-14), SQLite supports foreign key constraints. But enforcement of foreign key constraints is turned off by default (for backwards compatibility). To enable foreign key constraint enforcement, run PRAGMA foreign_keys=ON; Note, however, that future releases of SQLite might change so that foreign key constraints enabled by default. Careful developers will not make any assumptions about whether or not foreign keys are enabled by default but will instead enable or disable them as necessary. The application can also use a PRAGMA foreign_keys statement to determine if foreign keys are currently enabled. (I found only one reference to this in the forum...from fMaxV. Thank you.)
LiveCode 9.0.3 stable when released will use updated SQLite v3.26.0. Thanks LC.
I'd also like to personally thank all the people who have offered advice and help. Thank you especially to Klaus, Richard, DunbarX, Jacque, Bogs, [-hh], and Panos. This forum is the best thing LiveCode has going for it. Terry


 
 