Unanswered: Triggers and Stored Procedures in MySQL
I already did a lot of research but I can't find a working solution for this problem.
People tell me to look at Stored Procedures and Triggers, but I can't create those (at least not working ones..).
Maybe someone here knows how to solve this.
I've got 2 databases with different tables. In DB1 I have the table 'IEP' in which I have a column named iep (real name of a person) and one named name (name of a telephone). In DB2 I have a table 'cdr' in which I have a column src (source of a telephone call).
Asterisk automaticly sends data to the second database, and the src is allways a number. But I want this to be a name. The number can be matched with the 'name' column from the first database, and I need the 'iep' of that match..
I think it should be possible with some trigger functions, but I really don't know how.. can anyone help me?
Tnx in advance
To get a better idea of what I mean, I've written this trigger, but ofc it doesn't work..
CREATE TRIGGER change_src BEFORE INSERT ON cdr
FOR EACH ROW BEGIN
SET NEW.src = (SELECT iep FROM DB1.IEP WHERE name = NEW.src)