Hi

I have several DELETE of a table, I need to write SQL statements which does the reverse, instead of deleting data I want to keep the data I need. For example

Code:
DELETE
FROM SW_PERSON t
WHERE EXISTS
(SELECT 1
 FROM LISTA_ORDENES o
 WHERE o.order_id=t.swobjectid AND t.swtype='ORDER')
/
COMMIT
/
DELETE
FROM SW_PERSON t
WHERE t.swtype='ORDER' AND t.swobjectid IS NULL AND COMP_INST_ID IS NULL
/
COMMIT
/
DELETE
FROM SW_PERSON t
WHERE t.swtype IS NULL
/
COMMIT
/
DELETE
FROM SW_PERSON t
WHERE t.swtype='ORDER'
AND t.swobjectid IS NULL 
AND EXISTS
(SELECT 1
 FROM  OM_COMPANY_INST c, LISTA_ORDENES l
 WHERE c.COMP_INST_ID=t.COMP_INST_ID
 AND l.order_id=c.order_id)
/
COMMIT
/





DELETE
FROM OM_CONTRACT_TECHNICAL_SERV t
WHERE EXISTS
(SELECT 1 
FROM OM_CONTRACT_INST c, OM_CONTRACT_SERV s, LISTA_ORDENES l  
WHERE t.service_id=s.service_id 
AND s.contract_id=c.contract_id 
AND c.order_id=l.order_id)
/
COMMIT
/
DELETE
FROM OM_CONTRACT_TECHNICAL_SERV t
WHERE EXISTS
(SELECT 1 
 FROM OM_CONTRACT_INST c,OM_CONTRACT_SERV s 
 WHERE t.service_id=s.service_id 
 AND s.contract_id=c.contract_id 
 AND c.order_id IS NULL)
/
COMMIT
/




DELETE
FROM OM_CONTRACT_SERVICE t
WHERE EXISTS
(SELECT 1
FROM LISTA_ORDENES l,OM_SERVICE_INSTANCE s ,OM_WELCOME_PACK w
WHERE t.contract_service_id=w.contract_service_id 
AND w.service_instance_id=s.service_instance_id 
AND s.order_id=l.order_id 
AND l.order_type_id<>3)
/
COMMIT
/
DELETE
FROM OM_CONTRACT_SERVICE t
WHERE EXISTS
(SELECT 1
FROM LISTA_ORDENES l,OM_EMF e, OM_WELCOME_PACK w
WHERE t.contract_service_id=w.contract_service_id 
AND w.emf_ext_id=e.external_id 
AND e.order_id=l.order_id 
AND l.order_type_id=3)
/
COMMIT
/
I need to write a SQL which does the reverse. I dont have a single clue. It´s not that easy as I thought. I thought by reversing the conditions I would get things right but it does not seem so.

Anyone with experiences do this sort of "Reversing" SQL?

Cheers