@didier69: No, each query must be self contained basically. Here is the code I wrote to do just this (sorry I'm @ work and can't clean it up):
Code: Select all
Procedure DisplayTOC()
Protected string$ = "", num = 0, template, html$ = "", Dim category_name$(num), Dim item_number$(num)
If OpenDatabase(#dbaDatabase, "hash.db", "", "", #PB_Database_SQLite)
DatabaseQuery(#dbaDatabase, "SELECT * FROM Categories")
While NextDatabaseRow(#dbaDatabase)
category_name$(num) = GetDatabaseString(#dbaDatabase, 1)
num + 1
Redim category_name$(num)
Wend
For x = 0 To (num-1)
If DatabaseQuery(#dbaDatabase, "SELECT * FROM Documents WHERE Category = '" + category_name$(x) + "'")
html$ + "<font class=" + Chr(34) + "cattitle" + Chr(34) + ">" + category_name$(x) + "</font><br />"
While NextDatabaseRow(#dbaDatabase)
html$ + "<a href=" + Chr(34) + "hash.doc:" + GetDatabaseString(#dbaDatabase, 0) + Chr(34) + ">" + GetDatabaseString(#dbaDatabase, 2) + "</a> <br />"
Wend
EndIf
Next
template = OpenFile(#PB_Any, "toc.tem")
If template
While Eof(template) = #False
string$ + ReadString(template)
Wend
string$ = ReplaceString(string$, "{categories}", html$)
html$ = string$
CloseFile(template)
EndIf
SetGadgetItemText(#webContent, #PB_Web_HtmlCode, html$)
CloseDatabase(#dbaDatabase)
EndIf
EndProcedure
Basically, first query is saved to an array. Second query loops through array for it's query.
Example: Query #1 retrieves states and saves to array. End query. Start loop, each state is queried for capital city. End query.