I have table with tree structure, columns are id
, category
, parent_id
Now I need a copy a node and its child's to a another node, while copying, the category must be same, but with new id and parent_id..
My input will be node to copy
& destination node to copy
I have explained the tree structure in the image file..
i need a function to do so..,
PostgreSQL version 9.1.2
Column | Type | Modifiers
-----------+---------+-------------------------------------------------
id | integer | not null default nextval('t1_id_seq'::regclass)
category | text |
parent_id | integer |
Indexes:
"t1_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"fk_t1_1" FOREIGN KEY (parent_id) REFERENCES t1(id)
Referenced by:
TABLE "t1" CONSTRAINT "fk_t1_1" FOREIGN KEY (parent_id) REFERENCES t1(id)