Monday, April 02, 2007

Export Utility

First idea is write an engine that will copy data in xml before uninstall and store the data back before installation. But problem here is with auto generated key. If copy the data then we need not to copy auto generated key. And most of the table have auto generated key. If we restore the data then these key will regenerate again and it might be have different key value than previous. If auto generated key is different then we need to change all references of keys. This is the main problem otherwise this was so simple. Just we need to write a class that will use jdbc connection to any database and take data from database and copy it to xml file. In reverse for restore the database we only need to read xml data make query for insert and execute the insert query on database using jdbc. How to solve this problem?
One thing i can, this idea just i am thinking. insert the data one by one and get auto generated from inserted and compare this value with existing ID. if both match then commit otherwise delete the inserted record. Again insert the data with same record of deleted data. now i will get new incremented key and compare again. do same procedure till the match generated key and exist key. in case of oracle we need to insert the data. we need to only get next sequence no from respective seuence table. I think this would be work but i am not sure. I need to think more on it so it should work without any error.

No comments: