Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bach delete
Message
 
 
To
13/08/2003 08:26:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00819727
Message ID:
00819738
Views:
14
Hi Chaim,

To see how much overhead this code has, comment out DELETE command and run it. Most likely it's slow because the're a lot of records to delete. You can also use SQL commands to do the same.
* Get the list of ID's to be deleted from table4
SELECT DIST t4.id ;
	FROM table4 t4 ;
		JOIN table3 t3 ON t3.id = t4.table3id ;
		JOIN table2 t2 ON t2.id = t3.table2id ;
		JOIN table1 t1 ON t1.id = t2.table1id ;
		JOIN deleteid did ON did.myid = t1.id ;
INTO CURSOR crsDelIds		
* Delete		
DELETE FROM table4 ;
	WHERE id IN (SELECT id FROM crsDelIds)
>I have table with 3 million lines and I have to delete about 2 million from this - based on other table with 200000 lines.
>in the following example I want to delete 'table4' (grandson of grandson of table 'deleteid')
>The example working but it's very slow, there is a way to rush it?
>
select deleteid
>scan
>	select table1
>	if seek (deleteid.myid,'table1','myid')=.f.
>	loop
>	endif
>	scan while deleteid.myid=table1.myid
>		select table2
>		if seek (table1.dyid,'table2','dyid')=.f.
>			loop
>		endif
>		scan while table1.dyid=table2.dyid
>			select table3
>			if seek (table2.id,'table3','table2id')=.f.
>				loop
>			endif
>			scan while table2.id=table3.table2id
>				select table4
>				if seek (table3.id,'table4','table3id')=.f.
>					loop
>				endif
>				scan while table3.id=table4.table3id
>					delet in table4
>				endscan
>			endscan
>		endscan
>	endscan
>endscan
>Thanks in advance
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform