Jump to content

Trigger && SP prooblem


char0n

Recommended Posts

Hello, I never worked with SP/triggers in MySQL, I have this problem.
On webpage I'd like to show online users, so idea is very simple: in one select (SP)
make all necesary things. I begin with:
[CODE]
CREATE TRIGGER online_insert
AFTER UPDATE ON subs_online
FOR EACH ROW DELETE FROM subs_online
WHERE ts < (unix_timestamp() - 180);
--------------
CREATE PROCEDURE online_insert(ip char(15))
INSERT INTO subs_online (ip, ts)
VALUES (ip, unix_timestamp()) ON DUPLICATE KEY UPDATE ts=unix_timestamp();
IN PHP: $this->db->DbQuery("call online_insert('{$_SERVER['REMOTE_ADDR']}')");

But I get error:
query: call online_insert('84.47.19.168') error: Can't update table 'subs_online' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

I tried change "AFTER UPDATE" to something else, but nothing worked as expected. Could someone help me on this issue please ? Thanks a lot.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.