Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Exclamation Unanswered: Delphi + ADO + SQL Server 2000 - Key column information is.....

    I have the follow Trgger for update a table :

    CREATE TRIGGER UPDate_Clients ON dbo.Clientes
    FOR UPDATE
    AS
    UPDATE c
    SET c.Cliente = i.Cliente
    FROM Inserted i
    INNER JOIN Contratos c
    ON c.ID_Clientes = i.ID_Clientes

    It works wonderfull at SQL Server Enterprise Manager but if I try to Edit the table Clientes the follow msg arise :

    Key column information is insufficient or incorrect. Too many rows were affected by update.

    In the tables there´re Primary keys...

    How Solve this....
    Thanks a lot of.

    Leonardo Almeida
    Recife - PE - Brazil
    55-81-9152-5106

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: Delphi + ADO + SQL Server 2000 - Key column information is.....

    You seem to have more than one contratos per cliente, at least in your application case.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  3. #3
    Join Date
    Sep 2003
    Location
    Recife - PE - Brazil
    Posts
    28

    Re: Delphi + ADO + SQL Server 2000 - Key column information is.....

    Originally posted by DoktorBlue
    You seem to have more than one contratos per cliente, at least in your application case.
    Yes it has cos it´s a relation of 1:N...how to solve this?

  4. #4
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: Delphi + ADO + SQL Server 2000 - Key column information is.....

    Try this:

    CREATE TRIGGER UPDate_Clients ON dbo.Clientes
    FOR UPDATE
    AS
    UPDATE Contratos
    SET c.Cliente = INSERTED.Cliente
    WHERE Contratos.ID_Clientes = INSERTED.ID_Clientes


    Actually, this constructoin works fine for INSERT trigger, but for UPDATE, I would let the trigger oonly fire when Cliente changes.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

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