• Welcome, Guest. Please login.
October 19, 2021, 12:58:29 AM


Welcome to the SQLitening support forums!

Multiple Databases

Started by Jeffrey Smith, March 31, 2011, 05:49:24 PM

Previous topic - Next topic

Jeffrey Smith

I would like to open up to 10 databases read only and one more database to write the results.   I need to access all databases at once, sum the values from each record, then write the results.  I'm guessing I need to use slAttach.  The 10 databases have one table each, all named "Habitat".  I think that using the set number I can access each of the 10 databases using "slGetrow SetNum".  How do I reference the database I want to write to on the last line without creating a new table in one of the other 10 databases?

B = Dir$(CombinePath$)
If Len(B) > 0 Then
Kill CombinePath$
End If
SlOpen CombinePath$, "C"
  For Y = 1 To NumRfiles
    Afile$ = ReachPaths(Y) & ReachFiles(Y)
    A = "D" & Using$("#",Y)
    slAttach AFile$,A
    slSel "SELECT * FROM Habitat", Y    'With set number
    If Y = 1 Then
    ColumnNames = slGetTableColumnNames("Habitat")
    Replace $Nul With "," In ColumnNames
    End If
  Next Y
  slEXE "Create Table If Not Exists HabOut (" & ColumnNames & ")"

Jeffrey Smith

I guess I didn't need to use slAttach.  I opened all 10 databases I wanted to read from did, a slSel for each database with a different set number.  I opened the database I wanted to write to last.  Using slGetRow requires a setnumber and so does slf().