Search code examples
foxprovisual-foxpro

How to run more than 24 values in the visual foxpro in the "In" clause?


I am using foxpro 5.0

I am having more than 3000 records to run a query.For example my query is

delete from mytable.dbf where fieldname not in (1,2,3,......3909)

It wont execute.Because foxpro allow only 24 records in the In clause.How can I execute this query?
Any simplification ideas.


Solution

  • The following code demonstrates how you can delete records in one table based on the records in another table.

    CREATE CURSOR Table1 (pk I)
    INSERT INTO Table1 (pk) VALUES(1)
    INSERT INTO Table1 (pk) VALUES(2)
    INSERT INTO Table1 (pk) VALUES(3)
    INSERT INTO Table1 (pk) VALUES(4)
    INSERT INTO Table1 (pk) VALUES(5)
    
    CREATE CURSOR Table2 (pk I)
    INSERT INTO Table2 (pk) VALUES(2)
    INSERT INTO Table2 (pk) VALUES(4)
    
    
    DELETE FROM Table1 WHERE Table1.pk IN (SELECT Table2.pk FROM Table2)