Results 1 to 2 of 2

Thread: Update a Table

  1. #1
    Join Date
    May 2002
    Posts
    29

    Unanswered: Update a Table

    Hi,
    I have a problem. I need to update the primary key column value in table tabA. Table tabA has got a foreign key relation with table tabB. When I try updating table tabA with new values for the primary key column I get an primary key violation error as there are records in the child table with the values which I am goin to update in the parent table. Is the anyway to do this with deleting records in the child table or disabling the relationship between these tables. One roundabout solution I saw was to create a dummy record in tabA and when any record is getting updated in tabA replace the child nodes column values with dummy records and then after inserting the new values update the child table with new values. Can anyone please give me a better Solution.
    Thanks in advance.
    Regards
    Dinesh

  2. #2
    Join Date
    Apr 2002
    Location
    California, USA
    Posts
    482

    Cool

    Use:

    ALTER TABLE <table_name> CONSTRAINT <constraint_name> INITIALLY DEFERRED;

    Here is th explanation:

    Specify NOT DEFERRABLE to indicate that this constraint is checked at the end of each DML statement. If you do not specify either word, then NOT DEFERRABLE is the default.

    INITIALLY IMMEDIATE
    Specify INITIALLY IMMEDIATE to indicate that at the start of every transaction, the default is to check this constraint at the end of every DML statement. If you do not specify INITIALLY, INITIALLY IMMEDIATE is the default.

    INITIALLY DEFERRED
    Specify INITIALLY DEFERRED to indicate that this constraint is DEFERRABLE and that, by default, the constraint is checked only at the end of each transaction.

    Hope that helps,

    clio_usa
    OCP DBA
    Visit our Web site
    .
    .
    .

Posting Permissions

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