Quoting Marco Bambini <[EMAIL PROTECTED]>:

> Before this line:
> curRecord.Column("pathname") = thePath
> you should add:
> curRecord = New DatabaseRecord
> 
> You need to create a new DatabaseRecord for each insert inside the  
> loop...

Thanks Marco -

I've moved that out of the Dim into the loop.  Also, the issue of the rs 
returned from the select:

> >   Dim curRecord As DatabaseRecord
> >   Dim rs As New RecordSet
> >   Dim f As FolderItem
> >   Dim fs As TextInputStream
> >   Dim curline, thePath, theFile As String
> >
> >   f = GetFolderItem("/private/tmp/runoutput1.log", _
> >     FolderItem.PathTypeShell)
> >
> >   fs = f.OpenAsTextFile
> >
> >   While Not fs.EOF
> >     curline = fs.ReadLine
> >     If Left(curline, 3) = "VL:" Then
> >       // This gets the full file and path from the text file
> >       thePath = NthField(curline, "|", 6)
> >       // this gets the files path (dirname)
> >       thePath = dirname(thePath)
> >       // send the result to my Debug class
> >       Debug.Print "SQL Select: " + "select * from paths where  
> > pathname='" _
> >         + thePath + "'"
> >       rs = CatalogDB.SQLSelect("select * from paths where  
> > pathname='" _
> >         + thePath + "'")

> >       if CatalogDB.Error Then
That last line    ^^^^^^^^^^
Was changed to read:

       If rs.RecordCount <> 0 Then

and the lookups are now reacting properly.

I have one remaining issue - when I insert the record into the paths datatable, 
how can I determine what the rowID was for that table?  When I use the

  "thePathID = app.BRUCatalogDB.LastRowID"

command, I get the last rowid for any insert and the rowid's for the files 
table 
could be MUCH larger than the ID that was actually assigned to the path insert.

Here's my (sort-of) working code:

  Dim curRecord As DatabaseRecord
  Dim rs As New RecordSet
  Dim f As FolderItem
  Dim fs As TextInputStream
  Dim curline, thePath, theFile, theArchiveID, theLink As String
  Dim theVol, theQFA, thePathID, lnCount As Integer
  Dim theSize As Int64
  
  f = GetFolderItem("/private/var/lib/bru/tmp/brucat1.log", _ 
    FolderItem.PathTypeShell)
  
  fs = f.OpenAsTextFile
  
  lnCount = 0
  
  While Not fs.EOF
    curline = fs.ReadLine
    lnCount = lnCount + 1
    If Left(curline, 13) = "archive ID = " Then
      theArchiveID = NthField(curline, "= ", 2)
    ElseIf Left(curline, 3) = "VL:" Then
      theVol = Val(NthField(curline, "|", 3))
      theSize = Val(NthField(curline, "|", 4))
      theQFA = Val(NthField(curline, "|", 5))
      // This gets the full file and path from the text file
      thePath = NthField(curline, "|", 6)
      // this gets the files path (dirname)
      If InStr(thePath, Chr(0)) <> 0 Then
        thePath = NthField(thePath, Chr(0), 1)
        theLink = NthField(thePath, Chr(0), 2)
      Else
        theLink = ""
      End If
      thePath = dirname(thePath)
      theFile = filename(thePath)
      Debug.Print "SQL Select: " + "select * from paths where pathname='" _
        + thePath + "'"
      rs = App.BRUCatalogDB.SQLSelect("select * from paths where pathname='" _
        + thePath + "'")
      if rs.RecordCount = 0 Then
        curRecord = New DatabaseRecord
        Debug.Print "No matching records for " + thePath + " in paths table"
        EditField1.SelText = thePath + EndOfLine
        curRecord.Column("pathname") = thePath
        App.BRUCatalogDB.InsertRecord("paths", curRecord)
        thePathID = app.BRUCatalogDB.LastRowID
        Debug.Print "PathID " + Str(thePathID) + " = " + thePath
        curRecord = Nil
      Else
        Debug.Print "Recordset count = " + Str(rs.RecordCount) + ", " + _
          "Lastrow was " + Str(app.BRUCatalogDB.LastRowID)
        thePathID = Val(rs.Field("pathid").Value)
        Editfield1.SelText = "Path entry is " + Str(thePathID) + EndOfLine
      End If
      curRecord = New DatabaseRecord
      curRecord.IntegerColumn("pathid") = thePathID 
      curRecord.Column("filename") = theFile
      curRecord.Column("archiveid") = theArchiveID
      curRecord.IntegerColumn("volume") = theVol
      curRecord.Int64Column("filesize") = theSize
      curRecord.IntegerColumn("qfa_start") = theQFA
      curRecord.Column("linkpath") = theLink
      App.BRUCatalogDB.InsertRecord("files", curRecord)
    End If
    If lnCount \ 100 = 0 Then
      App.BRUCatalogDB.Commit
    End If
  Wend

Everything looks good except the rowID for the path may not actually match the 
inserted row value in the paths datatable.

Tim
--
Tim Jones
[EMAIL PROTECTED]

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to