Just the traditional swap algorithm

this would swap var1 with var 2

temp = var1
var1 = var2
var2 = temp

I just used this concept exept used loops to copy all the fields into temp arrays. The problem is, there is a stage where var1 and var2 are equal, the database doesn't like this since the primary keys are the same.