|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hi.
using mysql 5.0.27 and playing with triggers. a simple db: create table foo{ aa varchar (10), bb int auto_increment, cc varchar (10), } innondb i'm trying to figure out how to create a trigger, such that if the user does an insert into foo (cc) value ("www"); the table will concat the www with the 'id' value to produce: foo aa bb cc www-1 1 www i've been reviewing triggers, and various examples, and for the life of me, i can't figure out how to modify a field of the row or the item i'm triggering off of... any thoughts/comments/pointers would be ful!! thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
create table foo
(aa varchar(20), id integer, cc varchar(20)); delimiter | create trigger foo_ins before insert on foo for each row begin set new.aa = concat(new.cc,'-',new.id); end; | delimiter ; insert into foo (cc,id) values ('www',1); select * from foo; -----Original Message----- From: bruce [mailto:bedouglas@earthlink.net] Sent: Wednesday, December 19, 2007 7:59 PM To: 'mysql list' Subject: trigger question.. hi. using mysql 5.0.27 and playing with triggers. a simple db: create table foo{ aa varchar (10), bb int auto_increment, cc varchar (10), } innondb i'm trying to figure out how to create a trigger, such that if the user does an insert into foo (cc) value ("www"); the table will concat the www with the 'id' value to produce: foo aa bb cc www-1 1 www i've been reviewing triggers, and various examples, and for the life of me, i can't figure out how to modify a field of the row or the item i'm triggering off of... any thoughts/comments/pointers would be ful!! thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=joe@piscitella.com Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00 AM Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00 AM |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
hi joe...
thanks, and what you provided works... but you changed the tbl def... you're using an int, and you're passing the value to the tbl. in my situation, i'm using an auto_increment, and i can't seem to use the "create .... before..." as the auto_increment wouldn't be set prior to the row being created... any more pointers/thoughts/... thanks -----Original Message----- From: joe [mailto:joe@piscitella.com] Sent: Wednesday, December 19, 2007 7:33 PM To: 'bruce'; 'mysql list' Subject: RE: trigger question.. create table foo (aa varchar(20), id integer, cc varchar(20)); delimiter | create trigger foo_ins before insert on foo for each row begin set new.aa = concat(new.cc,'-',new.id); end; | delimiter ; insert into foo (cc,id) values ('www',1); select * from foo; -----Original Message----- From: bruce [mailto:bedouglas@earthlink.net] Sent: Wednesday, December 19, 2007 7:59 PM To: 'mysql list' Subject: trigger question.. hi. using mysql 5.0.27 and playing with triggers. a simple db: create table foo{ aa varchar (10), bb int auto_increment, cc varchar (10), } innondb i'm trying to figure out how to create a trigger, such that if the user does an insert into foo (cc) value ("www"); the table will concat the www with the 'id' value to produce: foo aa bb cc www-1 1 www i've been reviewing triggers, and various examples, and for the life of me, i can't figure out how to modify a field of the row or the item i'm triggering off of... any thoughts/comments/pointers would be ful!! thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=joe@piscitella.com Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00 AM Internal Virus Database is out-of-date. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17 - Release Date: 12/6/2007 12:00 AM -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=b...@earthlink.net |
|
![]() |
| Outils de la discussion | |
|
|