Recursive Store[copy] data with different ids

Viewed 12

I have category table which have parent-child relationship , consider below table

Id name parentId
001 cat1 null
002 cat2 null
003 cat3 null
004 cat4 001
005 cat5 004
006 cat6 005
007 cat7 006

I have fetched data recursively, now I need to store data same way but id is different and hence parentId is also changed.

so can anybody help me to resolve it? I need logic to store data in PostgreSQL

Thanks

0 Answers
Related