PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > trigger question..
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
trigger question..

Réponse
 
LinkBack Outils de la discussion
Vieux 20/12/2007, 02h59   #1
bruce
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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

  Réponse avec citation
Vieux 20/12/2007, 03h32   #2
joe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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


  Réponse avec citation
Vieux 20/12/2007, 04h06   #3
bruce
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: trigger question..

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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h13.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16995 seconds with 11 queries