Reputation: 427
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
Reputation: 175716
I guess you want:
SET NEW.confcode = FLOOR(RAND()*999999)+111111;
-- instead of
SET @confcode = FLOOR(RAND()*999999)+111111;
Upvotes: 1