sqlvisual-foxprofoxpro

FoxPro - What is incorrect about this SCAN FOR loop?


I get an error: 'command contains unrecognized phrase/keyword' when I try to run a Scan For loop that looks like:

SCAN FOR table2_data.item_id = table1_data.item_id AND table2_data.status LIKE '%loaded%'

Any thoughts on why this is incorrect?

For some reason it works with:

SCAN FOR table2_data.item_id = table1_data.item_id AND table2_data.status = ALLTRIM('loaded') 

Can I not use LIKE in a SCAN FOR loop?


Solution

  • Your second code is the way to go, except for a small correction:

    SCAN FOR table2_data.item_id = table1_data.item_id AND alltrim(table2_data.status) = 'loaded'
    

    You can also take casing into account and write that as:

    SCAN FOR table2_data.item_id = table1_data.item_id AND lower(alltrim(table2_data.status)) = 'loaded'