lundi 2 février 2015

How to update the parent/child of all rows in the tree (ltree)?


Here are my configurations:

DB type: postgresql (9.3 if that's necessary)

Table name: product_sections

Column names: section_id (integer) & section_path (ltree)


table_image


Detail:

I have one reference value: section_id: 15 & section_path: Automation_Solutionz. So, when I want to rename Automation_Solutionz to, say Chrome, I want all references of Automation_Solutionz to be updated.


FROM:



Automation_Solutionz
Automation_Solutionz.Test_Case_Creation
Automation_Solutionz.Test_Case_Creation.Automation
Automation_Solutionz.Test_Case_Creation.Manual


TO:



Chrome
Chrome.Test_Case_Creation
Chrome.Test_Case_Creation.Automation
Chrome.Test_Case_Creation.Manual




Similarly, when I update a value which is in the middle, it should rename those too. In the case above, Test_Case_Creation should be renamed to something like TestCase or anything else. The same goes for any item which is either in the middle, end or at the start.


Hope, I explained things correctly. Thanks in advance :)





Aucun commentaire:

Enregistrer un commentaire