MySQL Forums
Forum List  »  Triggers

Trigger to Combine Elements of Other Row Data?
Posted by: Cory Gehr
Date: February 25, 2011 07:51AM

Hey guys,

I'm pretty new to MySQL. I have my database and a web form that will let users enter data into the tables. I would like to create a trigger that will update a field in the row with a preset URL, plus a value from another field in the row whenever they add a new row or update one. The script I have so far is this:

USE mcsicweb;
CREATE TRIGGER add_bigchart_url BEFORE INSERT ON stockanalysis
FOR EACH ROW BEGIN
IF (NEW.bigcharturl IS NULL) THEN
NEW.bigcharturl = CONCAT('http://bigcharts.marketwatch.com/charts/big.chart?symb=';, NEW.ticker, '&compidx=aaaaa:0&ma=3&maval=50,,200&uf=0&lf=1&lf2=0&lf3=0&type=2&size=2&state=8&sid=2773712&style=320&time=8&freq=1&comp=NO_SYMBOL_CHOSEN&nosettings=1&rand=9193&mocktick=1');
END IF;
END;

However, I keep getting syntax errors. Can someone help me with this?

Thanks!

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger to Combine Elements of Other Row Data?
3194
February 25, 2011 07:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.