How to referesh the values before inserting in database

I am having a Document list on which i have a loop and i insert the values in that into database.But in certain case i have a node and in some i wont have , but the value inserted is equal to the previous value of that node. Eventhough the node is not present for that record.
Can any one help?