Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select for update usage

Author  Topic 

Adarshask
Starting Member

3 Posts

Posted - 2009-10-26 : 02:46:27
Hi,
1) I want to know whether the SELECT FOR UPDATE can be used to lock the records in a table without using a cursor?

DML:

create table product(
product_id number(4) not null,
product_description varchar2(20) not null
);

insert into product values (1,'Java');
insert into product values (2,'Oracle');
insert into product values (3,'C#');
insert into product values (4,'Javascript');
insert into product values (5,'Python');

So i have a table full of data:
Now i execute the statement below to lock the records

SELECT * FROM PRODUCT FOR UPDATE OF PRODUCT_ID;

So, on trying to update the PRODUCT_ID, an error should be raised, since the record would be locked.

UPDATE PRODUCT SET PRODUCT_ID = 100 WHERE PRODUCT_ID = 1;

But this update statement is getting executed without any problem?
Am i missing anything?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-26 : 05:01:14
see this
http://www.informit.com/articles/article.aspx?p=327394&seqNum=2


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Adarshask
Starting Member

3 Posts

Posted - 2009-10-26 : 06:28:23
quote:
Originally posted by webfred

see this
http://www.informit.com/articles/article.aspx?p=327394&seqNum=2


No, you're never too old to Yak'n'Roll if you're too young to die.



Thanks, But i need to achieve locking via SELECT FOR UPDATE in Oracle 10g...
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-26 : 06:47:16
This is a forum for MS Sql Server.
I think you can get a better help in a ORACLE forum.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -