If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Triggers and Stored Procedures in MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-09, 06:11
Seedje Seedje is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 12-02-09, 12:44
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
On DB2 take a look at federated server
Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On