SQL to make each document independent and CURRENT from a version tree

Hello,

I have 10 documents which are part of a version tree with the latest document 1.10 and CURRENT

I would like to destroy this version tree and make each of those 10 documents as 1.0, CURRENT (making them independent)

I have previously worked with putting multiple 1.0, CURRENT documents into a version tree at SQL level and see lots of posts around that, but unable to find a post that has SQLs for splitting a version tree into individual 1.0, CURRENT documents

Is there any additional step to consider than what I have here below

Considering an example as below where there are 2 documents in the version tree with 1.1 being CURRENT

At SQL level (just considering a dummy number here for ids)

select s.r_object_id, s.i_chronicle_id, s.i_antecedent_id, s.i_latest_flag, s.r_immutable_flag, s.i_direct_dsc, s.i_has_folder , r.r_version_label

from dm_sysobject_sp s, dm_sysobject_rp r

where s.r_object_id = r.r_object_id and s.i_chronicle_id = ‘1234‘;

r_object_id i_chronicle_id i_antecedent_id i_latest_flag r_immutable_flag i_direct_dsc i_has_folder r_version_label
1234 1234 0000000000000000 0 1 1 0 1.0
5678 1234 1234 1 0 0 1 CURRENT
5678 1234 1234 1 0 0 1 1.1

I would like to take this version tree and break the 2 documents into individual 1.0, CURRENT, such that the data looks as below

r_object_id i_chronicle_id i_antecedent_id i_latest_flag r_immutable_flag i_direct_dsc i_has_folder r_version_label
1234 1234 0000000000000000 1 0 0 1 1.0
1234 1234 0000000000000000 1 0 0 1 CURRENT
5678 5678 0000000000000000 1 0 0 1 CURRENT
5678 5678 0000000000000000 1 0 0 1 1.0

Would the below updates be the right approach

For document(s) that is/are not CURRENT

  1. Update i_latest_flag = 1, r_immutable_flag = 0, i_direct_desc = 0, i_has_folder = 1 for r_object_id = ‘1234’ in dm_sysobject_s table
  2. Insert new record r_object_id = ‘1234’, i_position = -2, r_version_label = ‘CURRENT’ in dm_sysobject_r table

For document that is CURRENT

  1. Update i_chronicle_id = ‘5678’ where r_object_id = ‘5678’ in the dm_sysobject_s table
  2. Update r_version_label to 1.0 in dm_sysobject_r table for r_object_id = ‘5678’ and r_version_label = 1.1

Message was edited by: jsachin

Related:

Leave a Reply