Jump to content

Metalzed

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Metalzed's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes. But I will have a lot more lines. But removed them to find the error. In forst Post you see the orginal Trigger.. Anyhow. Did the Trigger in PHP instead.
  2. What do you meen. ; = the delimiter right? Removed it. CREATE TRIGGER Tabort BEFORE UPDATE ON TBMembers FOR EACH ROW BEGIN SET NEW.LastUpdated = 5 END Got this Message #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 'END' at line 5
  3. Tryed another Trigger This isn't working. Whats wrong. CREATE TRIGGER Tabort BEFORE UPDATE ON TBMembers FOR EACH ROW BEGIN SET NEW.LastUpdated = 5; END
  4. Maby I am all wrong here but you can do like this. It depends of how big the database will be. How many cars and so on. TBCars CarID Name ModelID Hk ....... with all the values every car have TBStats StatID StatName TBCarStats CarID StatID (INT) StatValue (Varchar) In TBCar you have. CarID=1 Name="A bran new Volvo with everything you need" CarID=1 Name="A very cheap Ford " In TBStats you have. StatID=1 StatName="color" StatID=2 StatName="gears" StatID=3 StatName="AC" StatID=4 StatName="Image" In TBCarStats you have. StatID=1 CarID=1 Value="Brown" StatID=1 CarID=1 Value="Green" StatID=1 CarID=1 Value="Yellow" StatID=2 CarID=1 Value="5" StatID=3 CarID=1 Value="Yes" StatID=3 CarID=1 Value="No" StatID=4 CarID=1 Value="An image link" StatID=1 CarID=2 Value="Blue" StatID=2 CarID=2 Value="6" This will meen that Car Name : "A bran new Volvo with everything you need" Color : Brown or Green or Yellow Gears : 5 Image : A link AC : Yes Or No Car 2 "A very cheap Ford " Color : Blue Gears : 6 This way you can add any fact to the cars you like. Exampel you can add 5 colors to one car while just one to another. Or five image to one and so on. This is not a good way to do with the whole Database but for some of the Value it is a way. Hope it helps and that i didn't missunderstood your question
  5. I try to create my first trigger. Whats wrong with the code Error Message SQL query: CREATE TRIGGER UpdMember BEFORE UPDATE ON TBMembers FOR EACH ROW BEGIN ; MySQL said: #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 2 Here is the whole SQL query. Have tryed to delete diffrent stuff but it seems to be a Error on first row. CREATE TRIGGER UpdMember BEFORE UPDATE ON TBMembers FOR EACH ROW BEGIN DECLARE NTime DATETIME; DECLARE NDay SMALLINT; DECLARE NHour SMALLINT; DECLARE NMin SMALLINT; DECLARE NTurns INT; SET NTime=DATE_SUB(NOW(),OLD.LastUpdated); SET NDay=DAY(NTime); SET NHour=HOUR(NTime); SET NMin=MINUTE(NTime); SET NMin=NDay*1440+NHour*60+NMin; SET NTurns=FLOOR(NMin/5); NMin=NMin-NTurns*5; SET NEW.LastUpdated = DATE_SUB(NOW(),INTERVAL NMin MINUTE); SET NEW.Turns=OLD.Turns+NTurns; IF NEW.Turns>50 THEN SET NEW.Turns=50; END
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.