Subject | lock conflict on no wait transaction |
---|---|
Author | luisfelipepetrycabral |
Post date | 2002-02-19T22:15:12Z |
Hi,
I'm having a little problem with transactions and foreign keys, so I
hope someone can help me up...
To explane the problem I created this 2 tables, and one of them has a
foreign key to the other.
Example:
CREATE TABLE MASTER
(MASTER_KEY INTEGER NOT NULL
,MASTER_DUMMY VARCHAR(15));
ALTER TABLE MASTER
ADD PRIMARY KEY (MASTER_KEY);
CREATE TABLE DETAIL
(DETAIL_KEY INTEGER NOT NULL
,DETAIL_FK_MASTER INTEGER);
ALTER TABLE DETAIL
ADD PRIMARY KEY (DETAIL_KEY);
ALTER TABLE DETAIL
ADD CONSTRAINT FK_DETAIL_MASTER FOREIGN KEY (DETAIL_FK_MASTER)
REFERENCES MASTER (MASTER_KEY);
I have 2 applications, one that updates the MASTER table (App-A), and
another that inserts records in the DETAIL table (App-B). If App-A
starts a transaction, updates a row on MASTER table, and before it
commits the transaction App-B starts Txn, and trys to insert a row in
DETAIL table with the foreign key pointing to the same row updated by
App-A, I get this error message in App-B:
"lock conflict on no wait transaction violation of FOREIGN KEY
constraint "FK_DETAIL_MASTER" on table "DETAIL" ".
I've tryed with different isolation levels, but I allways get the
same error. What I don't really understand is that App-A updates the
MASTER_DUMMY field, not the MASTER_KEY that is referenced by the
foreign key of DETAIL table.
I'm using Firebird RC2 on WindowsNT 4.
I'll appreciate any kind of help on this...
Luis Felipe.
I'm having a little problem with transactions and foreign keys, so I
hope someone can help me up...
To explane the problem I created this 2 tables, and one of them has a
foreign key to the other.
Example:
CREATE TABLE MASTER
(MASTER_KEY INTEGER NOT NULL
,MASTER_DUMMY VARCHAR(15));
ALTER TABLE MASTER
ADD PRIMARY KEY (MASTER_KEY);
CREATE TABLE DETAIL
(DETAIL_KEY INTEGER NOT NULL
,DETAIL_FK_MASTER INTEGER);
ALTER TABLE DETAIL
ADD PRIMARY KEY (DETAIL_KEY);
ALTER TABLE DETAIL
ADD CONSTRAINT FK_DETAIL_MASTER FOREIGN KEY (DETAIL_FK_MASTER)
REFERENCES MASTER (MASTER_KEY);
I have 2 applications, one that updates the MASTER table (App-A), and
another that inserts records in the DETAIL table (App-B). If App-A
starts a transaction, updates a row on MASTER table, and before it
commits the transaction App-B starts Txn, and trys to insert a row in
DETAIL table with the foreign key pointing to the same row updated by
App-A, I get this error message in App-B:
"lock conflict on no wait transaction violation of FOREIGN KEY
constraint "FK_DETAIL_MASTER" on table "DETAIL" ".
I've tryed with different isolation levels, but I allways get the
same error. What I don't really understand is that App-A updates the
MASTER_DUMMY field, not the MASTER_KEY that is referenced by the
foreign key of DETAIL table.
I'm using Firebird RC2 on WindowsNT 4.
I'll appreciate any kind of help on this...
Luis Felipe.