Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

select for update query not working..

496012Mar 29 2006 — edited Mar 30 2006
hi i am tying to get this bit of ncode to work so i can then go to the next part of demonstrating a deadlock between two transactions. however i cannot go any further has my initial code does not work at all. here it goes


//////////User A////////////////////////////////
DECLARE
v_salary squad.salary%TYPE := 300;
v_pos squad.position%TYPE := 'Forward';

BEGIN
UPDATE squad
SET salary = salary + v_salary
WHERE sname = 'Henry';
FOR UPDATE;

UPDATE squad
SET position = v_pos
WHERE sname = 'Fabregas';


COMMIT;
END;

//////////////////////User B/////////////

DECLARE
v_salary squad.salary%TYPE := 200;
v_pos squad.position%TYPE := 'Forward';

BEGIN
UPDATE squad
SET position = v_pos
WHERE sname = 'Fabregas';
FOR UPDATE;

UPDATE squad
SET salary = salary + v_salary
WHERE sname = 'Henry';
FOR UPDATE;



COMMIT;
END;

//////////////////////////////////////

Basicly user a creats a lock and so does user b, user b enquires a lock from user a and vice versa i.e. a deadlock
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2006
Added on Mar 29 2006
7 comments
783 views