The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
defining variables em23 Shell Programming and Scripting 12 01-04-2009 02:49 PM
defining a printer in qconfig matheeq AIX 0 03-18-2008 11:55 AM
Defining X and Y Coordinates Inside A Window lesnaubr Shell Programming and Scripting 1 08-16-2007 08:19 AM
Defining Variables sailorliones UNIX for Dummies Questions & Answers 4 07-21-2006 03:09 PM
Defining variables at boot time ianf UNIX for Dummies Questions & Answers 7 01-07-2002 01:03 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-11-2009
figaro figaro is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 267
Problems with defining triggers

I am running the example from the following webpage:
MySQL :: MySQL 5.0 Reference Manual :: 12.1.11 CREATE TRIGGER Syntax
and the problem is that triggers cannot be defined for some reason:
Code:
CREATE DATABASE IF NOT EXISTS triggertest;
USE triggertest;
CREATE TABLE test1(a1 INT);
CREATE TABLE test2(a2 INT);
CREATE TABLE test3(a3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE test4(
  a4 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  b4 INT DEFAULT 0
);

delimiter |

CREATE TRIGGER testref BEFORE INSERT ON test1
  FOR EACH ROW BEGIN
    INSERT INTO test2 SET a2 = NEW.a1;
    DELETE FROM test3 WHERE a3 = NEW.a1;
    UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
  END;
|

delimiter ;
and the result is:
Code:
Error: 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 'delimiter | CREATE TRIGGER testref BEFORE INSERT ON test1 FOR EACH ROW BE' at line 1
The database is initially empty, no other tables or triggers. What is the exact problem here and how do I fix it? Thanks in advance.

Code:
# mysql -v
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 164
Server version: 5.1.28-rc FreeBSD port: mysql-server-5.1.28_1
  #2 (permalink)  
Old 09-26-2009
figaro figaro is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 267
The problem seems to have to do with the web form used. The code is correct and should be used within the mysql prompt/shell itself.
  #3 (permalink)  
Old 09-26-2009
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 423
I would also encourage you to use the manual for your version of mysql.

MySQL :: MySQL 5.1 Reference Manual :: 12.1.19 CREATE TRIGGER Syntax
  #4 (permalink)  
Old 09-26-2009
figaro figaro is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 267
Yes, thanks for pointing that out.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0