>select * from Student where Admtd = 1 ; > into cursor curNewStudents nofilter > >if _tally > 0 insert into dlyatten (code, date, type, category, scode, lCode, sec ) ; > select code, m.pDate, 1, "P", scode, lCode, Sec from curNewStudents >endif>My problem is this,i have already some records in dlyatten.category, When i use above sql its insert all new records.
INSERT INTO ... ; SELECT ... ; WHERE < Student Primary Key > NOT IN ; ( SELECT < Student Primary Key > FROM DlyAtten )You can actually put all your code into one INSERT - SQL:
INSERT INTO ... ; SELECT ... FROM Student ; WHERE < Student Primary Key > NOT IN ; ( SELECT < Student Primary Key > FROM DlyAtten ) ; AND Student.Admtd = 1