Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,348 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,139 people online right now. Registration is fast and FREE... Join Now!




[MySQL] REFERENCING problem

 
Reply to this topicStart new topic

[MySQL] REFERENCING problem

Alhazred
post 27 Sep, 2008 - 09:07 AM
Post #1


New D.I.C Head

*
Joined: 25 Jul, 2007
Posts: 29


My Contributions


I have a table called Account, with some coulmns (name, family_name, username, password, email), I need to start a trigger which starts a stored procedure only when an update is done to the Username column, not if I update any other column. I'm trying to do that as follows in the code. My DB is MySQL 5.1 Server.
I have a syntax error 'near REFERENCING NEW ROW AS new_user, OLD ROW AS old_user
FOR EACH ROW
ModificaUserna' at line 3

CODE

CREATE VIEW username_view
AS SELECT username
    FROM account;

CREATE TRIGGER modifica_username
AFTER UPDATE ON username_view
REFERENCING NEW ROW AS new_user, OLD ROW AS old_user
FOR EACH ROW
ModificaUsername(old_user.username_view, new_user.username_view);

Which is the problem? Is there another way to do what I need?
User is offlineProfile CardPM

Go to the top of the page

ajwsurfer
post 6 Oct, 2008 - 11:43 AM
Post #2


D.I.C Regular

Group Icon
Joined: 24 Oct, 2006
Posts: 292



Thanked 2 times

Dream Kudos: 50
My Contributions


Check out this article:

http://www.databasejournal.com/features/ms...cle.php/1479581

I use the
CODE

If update()
  begin
    ...
  end

or
CODE

  If update


in MS SQL Server 2005.

I bet the syntax is the same for MySQL, even though a lot of the syntax is different.
User is offlineProfile CardPM

Go to the top of the page

Hary
post 6 Oct, 2008 - 11:55 AM
Post #3


D.I.C Head

**
Joined: 23 Sep, 2008
Posts: 180



Thanked 13 times
My Contributions


Does MySQL know the REFERENCING keyword? It looks like it doesnt (I dont knwo the details, I'm using postgres for everything harder than basic selects)
User is online!Profile CardPM

Go to the top of the page

ajwsurfer
post 6 Oct, 2008 - 12:05 PM
Post #4


D.I.C Regular

Group Icon
Joined: 24 Oct, 2006
Posts: 292



Thanked 2 times

Dream Kudos: 50
My Contributions


On looking at this again, I cannot verify that my previous statement is correct. I simply cannot get any documentation to verify it. The article is about MS SQL not MySql.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 03:52AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month