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

(ver: 7.6) Simple Trigger code not working as expected?

2006-07-02       - By H

 Back
Just realized I didnt post the version # it is 7.6 (sorry for the 2nd post).
 
 
I am having trouble writing a successful trigger according to the sample code.
 (Gosh I am hoping the Forum isnt cross-posted to the list because I put this
in the forum as well).
 Below you will see:
a) A simple schema creation statement
b) A simple insert statement for some sample data
c) A simply written trigger that doesnt execute as expected
d) A sql statement written to exercise the trigger and the resulting Error
message
e) Cut and pasted MAXDB documentation from the TUTORIAL part (example code of
the online help)
 What I would like:
Someone to rewrite the trigger so it works or better yet explain why it isnt
working?
 Thanks in advance,
 Homer
 a) CREATE TABLE "CM"."TEST"
(
"ID" Fixed (8,0) NOT NULL,
"FLD1" Varchar (25) ASCII DEFAULT 'USER',
"FLD2" Varchar (22) ASCII DEFAULT 'USER',
"RCVAL" Integer,
PRIMARY KEY ("ID")
)
 b) Insert into test values (1,'a','b',99)
 c) CREATE TRIGGER UPDATE FOR CM.TEST
AFTER UPDATE
EXECUTE
(
TRY
 UPDATE CM.TEST SET FLD1 = 'After Update Worked' WHERE TEST.ID = :OLD.ID ;
 CATCH
IF $RC <> 0 THEN STOP ($RC,' unexpected error') ;
)
 d) update test set fld2 = 'g' where id = 1
---- Error -- ---- ---- ---- ---- ---- ---
Auto Commit: On, SQL Mode: Internal, Isolation Level: Committed
General error;-918 POS(1) unexpected error
update test set fld2 = 'g' where id = 1
 
 e)The cut and paste from the documentation
 Source Link
http://dev.mysql.com/doc/maxdb/en/08/db4940f0030272e10000000a155106/content.htm
 The sample code is as follows, note the inconsistancy: 100 in the code
indicates success yet the notes clearly state that 0 indicates success:
 CREATE TRIGGER hotel_update FOR hotel.hotel AFTER UPDATE EXECUTE
(TRY
IF NEW.hno <> OLD.hno
THEN UPDATE hotel.room SET hno = :NEW.hno WHERE hno = :OLD.hno;
CATCH
IF $rc <> 100
THEN STOP ($rc, 'unexpected error');)
 
" The $rc variable returns a numeric error code after the UPDATE statement has
been executed. The value 0 means that the statement was successfully executed."
 


 
   
-- ---- ---- ---- ---- ---- -----
Now you can have a huge leap forward in email: get the new Yahoo! Mail.