Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
Subject: mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Subject: Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
Subject: MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Subject: Re: Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Problem with trigger

Problem with trigger

2007-08-06       - By Linos

 Back
Reply:     1     2     3     4  

Hello all,
  i am trying to do a trigger that permits me be sure that when the users
inserts a row use a list of possible good values to any of the columns
from other table where i maintain this list, i would like to have this
list dynamic instead of a constraint because i dont want to touch the
constraint every time an item it is added, i have added this trigger in
the hotel schema to test the idea:

CREATE TRIGGER prueba_zip FOR HOTEL.HOTEL AFTER INSERT EXECUTE
(VAR
    LISTA CHAR(5);
 DECLARE HOTEL_ZIP_CURSOR CURSOR FOR
 SELECT ZIP FROM HOTEL.CITY;
 TRY
    FETCH HOTEL_ZIP_CURSOR INTO :LISTA;
    IF NEW.ZIP NOT IN (LISTA)
       THEN STOP ($rc, 'unexpected error');
 CATCH
    STOP ($rc, 'unexpected error segunda parte');
 CLOSE HOTEL_ZIP_CURSOR;)


when i try to do an insert with a zip not in hotel.city i have this:

---- Error -- ---- ---- ---- ---- ---- ---
Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
Integrity constraint violation;350 POS(1) Referential integrity
violated:HOTEL_ZIP_IN_CITY,HOTEL,HOTEL
INSERT INTO HOTEL.HOTEL VALUES ('2445','test','14011','test','test')

when i try with a valid zip i get this:

---- Error -- ---- ---- ---- ---- ---- ---
Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
General error;-28910 STOP(0) not allowed
INSERT INTO HOTEL.HOTEL VALUES ('2445','test','10019','test','test')

I suppose i have a problem in my trigger code but i cant understand very
well the maxdb procedure language, i think it would be very good to have
more usage examples in the maxdb documentation, thanks in advance.

Best Regards,
Miguel angel.

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/maxdb?unsub=mysql@(protected)