Aradmey
Aradmey

Reputation: 427

MySQL trigger does not work

I've been trying to create a MySQL Trigger in order to set a random value to a column called confcode which is used for authentication purposes.

The issue is, the value never sets after I insert a new row and keeps being empty.

I use phpMyAdmin to create the trigger, and these are the defines:

Trigger name:    confcode
Table:    ebaysales
Time:    BEFORE/AFTER (both don't work)
Event:    INSERT
Definition:    SET @confcode = FLOOR(RAND()*999999)+111111

The trigger itself gets inserted successfully, but doesn't seem to affect anything..

Upvotes: 1

Views: 58

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175716

I guess you want:

SET NEW.confcode = FLOOR(RAND()*999999)+111111;
-- instead of
SET @confcode = FLOOR(RAND()*999999)+111111;

Upvotes: 1

Related Questions