Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    Unanswered: Triggers and Stored Procedures in MySQL

    Hello,

    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

    PS:

    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)
    END

  2. #2
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    On DB2 take a look at federated server
    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •