Handling orphaned ORDITEM records in ForceField repository

 Sample SQL query to see if any ORDITEM records are orpahned.

i.e. if there are order items in the FF repository withour correcsponding orders.

This can cause havoc when trying to upload new orders and those order lines happen to collide with the orpahned order lines.

 
 

ForceField Host Database Query

 

ODBC Source: ForceFieldHost

 

Select Stmt: SELECT COUNT(*) FROM FORCEFIELD_ORDITEM i WHERE NOT EXISTS (SELECT ORDNUM FROM FORCEFIELD_ORDHEAD o WHERE o.ORDNUM = i.ORDNUM)

 

Query Results

 

Row Number

COUNT(*)

1

161


This means there are 161 orpahned order lines (in this example).


To delete the order lines, use the SQL stmt:

DELETE FROM FORCEFIELD_ORDITEM i WHERE NOT EXISTS (SELECT ORDNUM FROM FORCEFIELD_ORDHEAD o WHERE o.ORDNUM = i.ORDNUM)

 



Article Details

Article ID:
97
Date added:
2012-01-30 17:13:53
Views:
358
Rating (Votes):
(535)