Results 1 to 4 of 4

Thread: Join and update the tables

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Join and update the tables

    I have two tables..and join the two tables 'A' and 'B' using Plot number field name. When I delete the Plot number in the tables 'A' Why the plot number still exits in the tables 'B' in Microsoft Access ? Why it cannot update?Any idea to solve this

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Join and update the tables

    I can't remember off the top of my head whether Access allows you to specify that deletes should be cascaded on a foreign key. If it does then you need to set that to on.

    I don't think it does though and that means you're going to have to handle this from your code. That shouldn't be difficult, whenever you issue a delete against table A you need to issue a similar delete against table B.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Join and update the tables

    You can set Access to Delete (or Update) on FK's (Cascade option). Personnaly I never use this option and always do this manually. If the FK was set properly to start with this would not happen (cascade is off by default) and the parent could not be deleted if a child is present
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Join and update the tables

    Generally I'd agree with Gary that you're probably safer to use the foreign key to refuse the delete instead of cascade it and then handle deletes in your code by deleting any child records first. This gives you much more control over what's happening in your database.

    However, I have recently inherited a system from another company who control just about everything from within the database using triggers, sprocs etc. They made heavy use of foreign keys with a whole strategy surrounding enforcing integrity by both cascading or refusing deletes as apropriate. This works very well but does need alot of planning and documentation up front.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

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



Click Here to Expand Forum to Full Width