Oracle LOCK TEBLE for the session time?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
duda_y
Forum Newbie
Posts: 6
Joined: Mon Sep 02, 2002 10:39 am
Location: Argentina

Oracle LOCK TEBLE for the session time?

Post 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.
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

What kind of system? Unix? Win? Mac? Please specify.


Direwolf
duda_y
Forum Newbie
Posts: 6
Joined: Mon Sep 02, 2002 10:39 am
Location: Argentina

Linux RedHat 7.3

Post by duda_y »

My Oracle is 8.17 and runs on Linux RedHat 7.3
Thank you
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post 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
kamal
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:35 am
Location: Rome, Italy

Post 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
Last edited by kamal on Fri Sep 13, 2002 6:06 am, edited 2 times in total.
kamal
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:35 am
Location: Rome, Italy

Post by kamal »

I mean, maybe you knew all that, that locks only until a commit or rollback...

:oops:

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
duda_y
Forum Newbie
Posts: 6
Joined: Mon Sep 02, 2002 10:39 am
Location: Argentina

Post by duda_y »

The problem is when php script finishes it fulfiills commit automatically.
Post Reply