Deleting A Parent Item that has children

Results 1 to 2 of 2

Thread: Deleting A Parent Item that has children

  1. #1
    John Dvorak Guest

    Default Deleting A Parent Item that has children

    When I add a new page to my web site, I can specify an existing page as the Parent. What this means is that I can assign the "Job Listings" page to fall under the Human Resources page.<BR><BR>Thus, if the Human Resources Page has ID=2 (ID is the primary key in the DB), then when I create the Job Listings page(ID=21), it is assigned a ParentID of "2" (matching the ID of Human Resources)<BR><BR>The problem I have run into is this:<BR><BR>How do I handle the situation when a user wants to delete the Human Resources Page. Since this page has children, I need to inform the user of this and, if they agree, I need to create a delete statement that deletes all pages whose ParentID=2<BR><BR>Any ideas?

  2. #2
    jason Guest

    Default RE: Deleting A Parent Item that has children

    if you have a nicely normalized database, this can be done with complex statements, but generally i don&#039t bother, since it&#039s such a rare operation to carry out. if your table is linked properly, then you&#039ll need to clear all pages of that category, then clear the category, which is reasonably easy to achieve. <BR><BR>that&#039s the mechanism to use. often in large RDBs there is a field on each record for active or inactive - that&#039d be the way to go, just set the human resources page to inactive. i can&#039t be more specific without knowing how the dbase structure works<BR><BR>jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts