2016-01-29 21 views
0

如何在foxpro中搜索超過索引鍵匹配的匹配項?我想將表dl中的chosen字段更改爲T,對於ctwdl表中存在subdir字段匹配的所有行。對ctw中的所有行重複匹配搜索。 dl中等於subdir值的記錄不是按順序排列的。尋求不止一次表達式

目前,代碼退出與文件的端遇到消息上線改變chosenTdl記錄只匹配的ctw第一subdir值後17 do while not eof()嵌套循環。

select 0 
use ctw 

select 0 
use dl 
index on subdir to subdir.idx 

select ctw 

do while .not. eof() 

    select dl 
    seek ctw -> subdir 

    if found() 
     do while not eof() 
      replace chosen with .t. for ctw -> subdir = dl -> subdir 
      skip 
     enddo 
    endif 

    select ctw 
    skip 
enddo 

回答

0

你的編碼是非常古老的風格。你得到的錯誤,因爲:

取代第...

遍歷整個表並留下記錄指針在底部。然後做一個跳過會導致錯誤。

你的代碼也很難閱讀和遵循。我會修改它爲:

Update dl Set chosen = .T. Where subdir In (Select subdir From ctw) 
+0

不要從90's prgs中學習。 90年代是Foxpro 2.x天,VFP是一種不同的野獸(就像一種新的和不同的語言)。您也可以使用www.foxite.com和www.universalthread.com等網站。這些仍然是生動的foxpro特定論壇。即使從90年代起,上面的代碼也不好,改變你的來源。 –