Board index » off-topic » Record Lock Failed.. Revisited

Record Lock Failed.. Revisited


2004-09-24 10:52:57 PM
off-topic18
Can someone tell me why Code #1 works, but Code #2 gives a Record Lock
Failed on the 2nd Execute Statement? They technically are updateing the same
record, so why is it having trouble? Is there anyway I can get around this?
Note: This is just a small example of a much bigger problem for me, so just
removing the added section in the Where clause is not an option. Just
hopeing for an explanation of why it doesnt work.
Code #1:
Database1.StartTransaction;
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "22" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "33" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
Database1.Commit;
Code #2:
Database1.StartTransaction;
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "22" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "33" where
"biolife.db"."Species No" = "90050" and "biolife.db"."Category" = "22"';
Database1.Execute(SQLStmnt);
Database1.Commit;
TIA,
Timothy Armstrong
 
 

Re:Record Lock Failed.. Revisited

Wouldn't the query
UPDATE "biolife.db" SET "biolife.db"."category" = "33" WHERE
"biolife.db"."Species No" = "90050"
Get you the same results?
"Timothy Armstrong" < XXXX@XXXXX.COM >wrote:
Quote
Can someone tell me why Code #1 works, but Code #2 gives a Record Lock
Failed on the 2nd Execute Statement? They technically are updateing the same
record, so why is it having trouble? Is there anyway I can get around this?

Note: This is just a small example of a much bigger problem for me, so just
removing the added section in the Where clause is not an option. Just
hopeing for an explanation of why it doesnt work.

Code #1:
Database1.StartTransaction;
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "22" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "33" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
Database1.Commit;

Code #2:
Database1.StartTransaction;
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "22" where
"biolife.db"."Species No" = "90050"';
Database1.Execute(SQLStmnt);
SQLStmnt := 'update "biolife.db" set "biolife.db"."Category" = "33" where
"biolife.db"."Species No" = "90050" and "biolife.db"."Category" = "22"';
Database1.Execute(SQLStmnt);
Database1.Commit;


TIA,

Timothy Armstrong