Results 1 to 11 of 11

Thread: VB6,Sql7,delete records using diagrams

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Post

    Hi,

    I am using diagrams in Sql 7 to connect some tables one to anoher. (Father table and sons) Like I was doing with access.
    When I am trying to delete the Father record
    I am getting error.
    What is the appropriate syntax to do so?

    Thanks,

    Gil

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    did you (indirectly or directly) add a constraint to your tables so that a parent record must correspond to each child record?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Post

    If you mean the constraint that appear in the table folder then no. I don't know what to write there.
    Gil

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    You can write a trigger to issue a delete on the child...

  5. #5
    Lively Member
    Join Date
    Aug 1999
    Posts
    89

    Post

    this could be because of referential integrity. You are trying to delete a record in the father table which is used by the child. So when you delete, make sure it is a cascade delete.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Post

    Thank you all.

    1. How do I write triggers for this missions?
    2. What is a cascade delete?

    I tried to look in the sql documentation but I didn't find any. Does anyone know where it is in the documentation?

    Gil

  7. #7
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    You'll have to write the triggers to support a cascade delete (SQL Server 6.5 doesn't have cascade deletes, not sure about 7.0 but I suspect it doesn't also).

    A cascade delete deletes records in associated tables when you issue a delete on one or more tables. The term comes from hierarchical databases that have parent-child structures. Hierarchical databases, for the most part, lost out to relational databases in the secret database wars.

    As an example, a delete trigger might look like:

    CREATE TRIGGER CascadeExample
    ON table1
    FOR DELETE
    AS

    Delete table2 from deleted a, table2 b
    where a.uniquekey=b.uniquekey

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Post

    Thanks,
    The Cascade delete works.
    But I still have problems with the diagrams.
    Meanwhile I disconnect them but I don't think that it is the right solution.
    I am still looking for a way to prevent errors while performing delete within connect tables.

    Gil

  9. #9
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    If the cascade delete works, what error messages are you getting?

  10. #10
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    You will need to add a trigger for every table that has RI to the one you're deleting.

  11. #11

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    11

    Post

    The error I am getting is: DELETE statement conflicted with COLUMN REFERENCE constraint...
    I need the diagrams for automatic update between tables as it is in access.
    If I have to write triggers then I don't think that I need the diagrams.

    Gil

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