jcook331
29th April 2008, 03:13
We have developed some engineering programs and we are trying to do a data conversion for one of our companies. The records on this table are revision controlled and we are trying to raise the revision on some of the records. To do this we are creating a new record with a higher revision that is exactly the same as the previous revision. Is there a way to read a table and then copy the record you are reading into the same table and change one field?
bdittmar
29th April 2008, 10:15
We have developed some engineering programs and we are trying to do a data conversion for one of our companies. The records on this table are revision controlled and we are trying to raise the revision on some of the records. To do this we are creating a new record with a higher revision that is exactly the same as the previous revision. Is there a way to read a table and then copy the record you are reading into the same table and change one field?
Hello,
you have only to update the records with the new field value.
select table for update
set new field value
db.update(table)
Regards
grzegorz
29th April 2008, 13:11
Your code should look like this:
|***************************|
table txxyyy999
long counter
db.retry.point()
counter = 1
select xxyyy999.* from xxyyy999 for update
where <your selection criteria>
as prepared set
selectdo
xxyyy999.revi = xxyyy999.revi + 1
db.insert( txxyyy999 , db.retry )
counter = counter + 1
if counter > 50 then
commit.transaction()
counter = 1
endif
endselect
commit.transaction()
|**************************|
I assume that xxyyy999.revi is a part of multifield primary index, so increment gives an unique key.
jcook331
30th April 2008, 00:02
That worked great! Thanks