Table Structure
ID DESC PARENT_ID**
35151 Parent 35154
35152 System 35151
35153 Same as System 35151
35154 ParentsParent 35157
35156 Product 35157
35157 Login Group 35159
Where
Id is the primary key, and parent_id is the foreign key referenced in the same table
How can I delete records recursively, starting from the last child till the parent. If there is no child records the parent record should be deleted. I need to use transaction with rollback if something odd happens. Help appreciated