• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

find first problems


   recursion. before each iteration i check at the beggining of the recursion if the specific node
   was not already inserted to the table because in this tree a certain node might be located
   under several nodes in diffrent levels of the tree. on the second entry to the recurion after
   inserting one record to the table, the debuger stops at this line saying there is a syntax
   error(an operator missing):

   tbl.findfirst ("where objectid="+format(objectid)+" and FObjId="+format(fatherobjectid))

   where objectid and fatherobjectid are longs and the fields name are objectid and fobjid. i
   should remind you that on the first entry to the recursion it did commit this line and only on
   the second entry it stopped.

   Private Sub RecursTree(ByVal ObjId As Long, ByVal FatherObjId As Long, ByVal level
   As Integer, Table As Recordset, CurrentDb As Database)
   Dim SPrtId As String
   Dim parameterlst As Long
   Dim RetCode As Integer
   Dim Cnt As Integer
   Dim SonsList As Long
   Dim PrtList As Long
   Dim SonPrtList As Long
   Dim PrtClsId As String
   Dim PartClsId As Long
   Dim SObjId As String
   Dim i As Integer
   Dim strquery As String

   parameterlst = RECLST_Create(ApplHndl, 1)
   PrtList = RECLST_Create(ApplHndl, 1)
   SonsList = RECLST_Create(ApplHndl, 1)
   'With Table
   ' strSQL = ("where FObjId=" + Format(FatherObjId) + " and SObjId=" + Format(ObjId))

   '  .FindFirst strSQL
   '  If .NoMatch = True Then
         If FatherObjId <> 0 Then
               Call UpdLinksTbl(FatherObjId, ObjId)
         End If
         With Table
         SObjId = String$(20, " ")
         SPrtId = String$(20, " ")
         PrtClsId = String$(20, " ")
         .AddNew
         !FObjId = FatherObjId
         !SObjId = ObjId
         !level = level
         RetCode = RECLST_AddElValAsPChar(ApplHndl, parameterlst, "1", "CLASS_ID",
   50, TDMT_CHAR)
         strquery = "select CLASS_ID from TN_ITEMS where OBJECT_ID=" + CStr(ObjId)

         RetCode = TDMDB_RunQuery(ApplHndl, strquery, parameterlst,
   TDM_SELFLEXIBLE, PrtList, 0)
         'RECLST_Print ApplHndl, "PrtList", PrtList, 1
         RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, PrtList, "CLASS_ID", 0,
   PrtClsId, 20, "")
         'RetCode = CLS_GetObjClsIdByObjId(ApplHndl, PSupperClsId, ObjId, PartClsId,
   0) as integer
         PrtClsId = Trim(PrtClsId)
         PrtClsId = Mid(PrtClsId, 1, Len(PrtClsId) - 1)
         If Val(PrtClsId) = CPClassId Then
             !Configurable = 1
         Else
             If Val(PrtClsId) = NSPClassId Then
                 !Configurable = 2
             Else
                 !Configurable = 3
             End If
         End If
         .Update
         .Bookmark = .LastModified
       End With
       SonPrtList = RECLST_Create(ApplHndl, 1)
       RetCode = CLS_GetObjectSons(ApplHndl, Val(PrtClsId), ObjId, SonPrtList)
       If RetCode = ERR_NONE Then
         Cnt = RECLST_GetRecordCnt(ApplHndl, SonPrtList)
         If Cnt <> 0 Then
             For i = 1 To Cnt
                 RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, SonPrtList,
   CStr(PSupperClsId) + ".OBJECT_ID", i - 1, SObjId, 20, "")
                 'RECLST_Print ApplHndl, "SonPrtList", SonPrtList, 1
                 Call RecursTree(Val(SObjId), ObjId, level + 1, Table, CurrentDb)
             Next
         End If
       End If
   'End If
   'End With
   RetCode = RECLST_Free(ApplHndl, parameterlst)
   RetCode = RECLST_Free(ApplHndl, SonsList)
   RetCode = RECLST_Free(ApplHndl, PrtList)
   RetCode = RECLST_Free(ApplHndl, SonPrtList)
   End Sub

   Private Sub UpdLinksTbl(FObjectId As Long, ObjectId As Long)
   Dim CurrentDb As Database
   Dim Table As Recordset
   Dim RetCode As Integer
   Dim LinkAttrRecList As Long
   Dim strsql As String
   Dim parameterlist As Long
   Dim Squantity As String

   Squantity = String$(20, " ")
   parameterlist = RECLST_Create(ApplHndl, 1)
   Set CurrentDb = OpenDatabase(configDB)
   Set Table = CurrentDb.OpenRecordset("TreeLinks", dbOpenDynaset)
   LinkAttrRecList = RECLST_Create(ApplHndl, 1)
   'RetCode = CLS_GetHierObjByRelObjIds(ApplHndl, 7, ObjectId, FObjectId,
   LinkAttrRecList, 1)
   'RECLST_Print ApplHndl, "TreeLinks ", LinkAttrRecList, False
   Call RunQAQuery(QClassId, "ITEMS_TREE", "PAR_OBJECT_ID", FObjectId,
   parameterlist) ' possible to replace
   With Table
         RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, parameterlist, CStr(7) +
   ".CN_QUANTITY", 0, Squantity, Len(Squantity) + 1, "")
        .AddNew
        !FObjId = FObjectId
        !SObjId = ObjectId
        !Quantity = Val(Squantity)
        .Update
        .Bookmark = .LastModified
   End With
   RetCode = RECLST_Free(ApplHndl, LinkAttrRecList)
   RetCode = RECLST_Free(ApplHndl, parameterlist)
   Table.Close
   CurrentDb.Close
   End Sub

   this is the code lines. don't mind the commands with Retcode and RECLST_ etc. these are
   api functions of a certain software i'm integrating with. all these commands return correct
   values, they are not the reason for my problem. when i cancel the checking of existing nodes
   i'm getting the right table but a very long one. when i add the find first, it works on the first
   entry to the recursion but then on the next one it says there is a syntax error.
   please help, thank you.
0
ilanm
Asked:
ilanm
1 Solution
 
idcanadaCommented:

Maybe you can email me a working sample of this.
I am getting many errors simply because I do not have the proper files or actions.
It is hard to debug simply by viewing...

0
 
vikiingCommented:
I believe the first portion of your message is missing. Could you specify what is the problem you have?
0
 
ilanmAuthor Commented:
helo viking
the beggining is :
i try to map atree to a table using vb6. the table is on access 97. i'am doing that by a recursion.

hello idcanada
i can't send you a piece of the code cause you don't have the other software which i integrate with, but the api commands retrieve right values so you can just ignore them and check the vb commands.

thank you very much.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ilanmAuthor Commented:
didn't get an answer
0
 
cedricdCommented:
.findfirst ("....=... and ... = .... ") (don't use where)
strSQL = ("FObjId=" + Format(FatherObjId) + " and SObjId=" + Format(ObjId))

0
 
cedricdCommented:
oups :
tbl.findfirst ("objectid="+format(objectid)+" and FObjId="+format(fatherobjectid))

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now