i am trying to make a trigger. But my trigger generates me an error i can not explain.
This is my trigger code:
Expand|Select|Wrap|Line Numbers
- -- This script has been created using ^ as the termination character.
- -- If you wish to execute this script through the CLP, you will need
- -- to add the CLP option -td"^" to your command line, for example:
- -- db2 -td"^" -f filename.ddl
- CONNECT TO DACODB2^
- CREATE TRIGGER FASTMAIN.TR_TEST NO CASCADE BEFORE INSERT ON FASTMAIN.IMP_TAB_RECORDS REFERENCING NEW AS NEW_KEY FOR EACH ROW MODE DB2SQL
- BEGIN ATOMIC
- --
- DECLARE proc_pointer_from INTEGER DEFAULT 0;
- DECLARE proc_pointer_to INTEGER DEFAULT 0;
- DECLARE proc_pointer_last INTEGER DEFAULT 0;
- DECLARE proc_pointer_incr INTEGER DEFAULT 0;
- --
- --
- SET (proc_pointer_from,proc_pointer_to,proc_pointer_last,proc_pointer_incr)=(SELECT pointer_from,pointer_to,pointer_last,pointer_increment FROM pointer WHERE pointer_id='IMP001');
- --
- --
- SET proc_pointer_last=proc_pointer_last+proc_pointer_incr;
- IF proc_pointer_last>proc_pointer_to THEN
- SET proc_pointer_last=proc_pointer_from;
- END IF;
- --
- --
- UPDATE pointer SET pointer_last=proc_pointer_last WHERE pointer_id='IMP001';
- --
- --
- SET NEW_KEY.IMPTR_KEY=proc_pointer_last;
- --
- END^
- CONNECT RESET^
But DB2 has a problehm with the folowing statement of my code:
„UPDATE pointer SET pointer_last=proc_pointer_last WHERE pointer_id='IMP001';
“
When i try to create my trigger DB2 says :
"The trigger "FASTMAIN.TR_TEST" is defined with an unsupported triggered SQL "
Pleasy help me i have no idea why this normal SQL statement is not correct.
an exuse me for my bad english :-)
Greeetings