triggers, stored procedures
Posted by: Mr Fragas (201.62.90.---)
Date: April 02, 2008 03:24AM

Hello, i think I'm the newest member in this forum, i use wampserver to develop some academic aplicattion, and i wonder if it's possible to use triggers and stored procedures. In case of yes how.
Thanks.

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: toivo (---.belrs4.nsw.optusnet.com.au)
Date: April 02, 2008 12:51PM

Hi,

[dev.mysql.com]

[dev.mysql.com]

Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: Mr Fragas (201.62.90.---)
Date: April 02, 2008 11:16PM

Hi, Toivo thans for you attention, but the problem isn't solved till now, as i said i use wampsever 2, and when i try to create a trigger with this script:


create trigger upper_table
before insert on documents
for each row
begin
set @docName = upper(NEW.docName);
end;


i get this:

Mensagens do MySQL :

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5

can you help me

Mr Fragas

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: toivo (203.19.130.---)
Date: April 04, 2008 03:39PM

Hi,

This version should work:

create trigger upper_table
before insert on documents
for each row
set @docName = upper(NEW.docName);

The begin - end syntax seems to require multiple statements...

Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: Mr Fragas (201.62.90.---)
Date: April 04, 2008 05:39PM

Yes, Toivo it worked thanks, but there's a new little problem, i think the upper command didn't work because if insert "hello world" on the table it doesn't change, it still be "hello world" don't you think?
Thanks for your help

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: toivo (---.nsw.bigpond.net.au)
Date: April 04, 2008 10:58PM

Hi,

Isn't @docName a MySQL variable? That means it is not the same as the column docName in your table and when the variable is updated, the column does not change. You would need to store it in a particular row in a table in the next SQL statement for your method to work. More details at [dev.mysql.com].

Regards,

toivo
Sydney, Australia

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: Mr Fragas (201.62.90.---)
Date: April 08, 2008 12:56AM

Hi Toivo
Now it worked very well, the sintax is correct but it should be NEW.nameDoc = upper(NEW.nameDoc);
now it´s ok.
Thanks for your big help
MR Fragas

Options: ReplyQuote
Re: triggers, stored procedures
Posted by: toivo (---.nsw.bigpond.net.au)
Date: April 08, 2008 10:36AM

Cheers :-)

toivo
Sydney, Australia

Options: ReplyQuote


Sorry, only registered users may post in this forum.