titorober23
asked on
verify if record exist before updating (migration vb program)
Hi Guys
I have vb program to migrate records from old db to a new model.
This is the situation
tbl-Old
ID CustID Location
1 1 Newark
2 1 Denver
3 1 NY
4 1 NY
5 1 Newark
New-Model
ID CustID Location
1 1 Newark
2 1 Denver
3 1 NY
This is how it should be transfer, so before i update the new record, i have to verify if the CustID and Location already exist
I have the code that will transfer everything without comparing or verifying is it exist
Any comments
I have vb program to migrate records from old db to a new model.
This is the situation
tbl-Old
ID CustID Location
1 1 Newark
2 1 Denver
3 1 NY
4 1 NY
5 1 Newark
New-Model
ID CustID Location
1 1 Newark
2 1 Denver
3 1 NY
This is how it should be transfer, so before i update the new record, i have to verify if the CustID and Location already exist
I have the code that will transfer everything without comparing or verifying is it exist
Any comments
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good. Fire a select query from both old and new tables while passing columns as parameters to your function so that if boolean returned is TRUE, then do not carry out the migration of these records else do so for the rest.
The other way is to let the code be as is developed and just introduce error/exception handling code where by if constraint violation prevents the migration, then dummy handle the vilation error/exception. It is not just a question of CustID and Location already existing but here more a question of PK ID in source and target both being present before data migration takes place.
If only one connection is possible at a time like in stored procedures, then link the databases/their tables like we have db link in Oracle, nicknames in DB2 and four part name in SQL Server and Sybase i.e. server.db.schema/owner.obj