PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > How to Change a Value on Insert
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to Change a Value on Insert

Réponse
 
LinkBack Outils de la discussion
Vieux 31/03/2008, 23h00   #1
AAFShini@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to Change a Value on Insert

I'm not sure is this possible or not.
Suppose I have a Table with these fileds

id
Name
Duration
Prefix

And the Insert is: Insert (id, name, duration, prefix) values ( 10,
test, 30, pr#)

I want to check the value of Prefix, If it is tt# then the Duration
should change to: duration + 5, Otherwise it is the same.

I don't want to change this in the Code Level (PHP, Ruby) which mean I
don't want to check it before the Insert Command, I want to know is
there a way to do so with MySQL itself at the time of the insert, with
Procedures, Constraint check or something else.

Thank you in Advance

  Réponse avec citation
Vieux 31/03/2008, 23h10   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to Change a Value on Insert

On Mon, 31 Mar 2008 23:00:02 +0200, <AAFShini@gmail.com> wrote:

> I'm not sure is this possible or not.
> Suppose I have a Table with these fileds
>
> id
> Name
> Duration
> Prefix
>
> And the Insert is: Insert (id, name, duration, prefix) values ( 10,
> test, 30, pr#)
>
> I want to check the value of Prefix, If it is tt# then the Duration
> should change to: duration + 5, Otherwise it is the same.
>
> I don't want to change this in the Code Level (PHP, Ruby) which mean I
> don't want to check it before the Insert Command, I want to know is
> there a way to do so with MySQL itself at the time of the insert, with
> Procedures, Constraint check or something else.


http://dev.mysql.com/doc/refman/5.0/...e-trigger.html
--
Rik Wasmus
  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 01h55.


É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,07226 seconds with 10 queries