Hi,
I have a DB-Application and now we have to start with replication (master-master-replication). We build an stored-function witch returns an BIGINT. This value is unique on all involved servers.
The situation: I have a table definition:
create table test (
id BIGINT not null primary key auto_increment,
col1 TEXT);
the table has an before insert trigger:
CREATE TRIGGER test_insert BEFORE INSERT ON test
FOR EACH ROW BEGIN
IF NEW.id = 0 THEN
SET @my_uuid = MYUUID();
SET NEW.id = @my_uuid;
END IF;
END;
after an insert into test (col1) values ("foo") I need the value of the LAST_INSERT_ID() - but I only get the value "0".
I try´d this in the trigger:
SET NEW.id = LAST_INSERT_ID(@my_uuid);
but it don´t work.
I read the mysql manpage witch says, that all changes on last_insert_id within triggers and functions will be canceled at the end of the trigger.
So I try to avoid changing the application (witch use php.last_insert_id())...
any ideas how to solve this without changing php-code?
greatings.