Page 1 of 1
Oracle LOCK TEBLE for the session time?
Posted: Thu Sep 12, 2002 7:42 am
by duda_y
Hello, php gurus.
Need to lock tables in my web application not tor the time
the script run, but for the time the session lasts or the user
unlocks it in the next script.
Any ideas?
Thank you.
Posted: Thu Sep 12, 2002 10:45 am
by Johnm
What kind of system? Unix? Win? Mac? Please specify.
Direwolf
Linux RedHat 7.3
Posted: Thu Sep 12, 2002 11:47 am
by duda_y
My Oracle is 8.17 and runs on Linux RedHat 7.3
Thank you
Posted: Thu Sep 12, 2002 12:05 pm
by Johnm
write a shell script to do what you want and have the php script call it with something like the system() function. I do not think that PHP can do what you want. Although I may be wrong.
Direwolf
Posted: Fri Sep 13, 2002 5:35 am
by kamal
There's an oracle SQL command called
LOCK TABLE.
You can find it in the oracle sql reference book.
(
pdf or
on-line).
You can write a stored procedure that does it (for example through native dynamic SQL), and then call it from PHP.
For example:
Code: Select all
CREATE PROCEDURE lock_table (
table_name VARCHAR2,
lock_mode VARCHAR2,
no_wait BOOLEAN DEFAULT false)
IS
v_no_wait CHAR(6) := NULL;
BEGIN
IF no_wait THEN v_no_wait := 'NOWAIT';
END IF;
EXECUTE IMMEDIATE 'LOCK TABLE ' || table_name || ' IN ' ||
lock_mode || ' MODE ' || v_no_wait;
END lock_table;
Obviously the table must be yours or you need the "lock any table" system privilege.
I hope this helps.
Kamal
Posted: Fri Sep 13, 2002 5:47 am
by kamal
I mean, maybe you knew all that, that locks only until a commit or rollback...
I hope it helps the same.
I understand I'didn't read the message very well, taken by the will to help.
If that's english.
Ok.
Kamal
Posted: Fri Sep 13, 2002 3:54 pm
by duda_y
The problem is when php script finishes it fulfiills commit automatically.