Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting rowid from Oracle in php

Status
Not open for further replies.

newbiepg

Programmer
Nov 6, 2002
181
IN
I need to ensure that while one user edits a row in the backend(oracle 8i) , no other user can get access to edit(row level locking).

We are using oci functions and I thought that getting the row id would be a good way to solve this problem.

How can we get rowid in oracle using php and what datatype would that be ?
 
Your best bet is to search on the web for "optimistic locking". I saw a good Oracle example which used stored procedures to provide the functionality. Just using the rowid isn't good enough as that might not change, you have to be confident that the row has not changed. The most common way is to have a count column on the record which gets incremented each time the row changes e.g. update fred set name="billy" rowcnt=rowcnt+1 where rowcnt=:storedrowcout (+ some other key info). Note that the where clause looks for the rowid being the same as when it was selected, if it isn't the update will fail as someone has been there before you. Using stored procedures to do takes away the responsability of the programmer to code it in each time.

regards

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top