Connecting Tech Pros Worldwide Forums | Help | Site Map

Problems with a simple Trigger :-(

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 7 '08
Helo everybody
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
  1. -- This script has been created using ^ as the termination character.
  2. -- If you wish to execute this script through the CLP, you will need 
  3. -- to add the CLP option -td"^" to your command line,  for example:
  4. -- db2 -td"^" -f filename.ddl
  5.  
  6. CONNECT TO DACODB2^
  7. CREATE TRIGGER FASTMAIN.TR_TEST NO CASCADE BEFORE  INSERT  ON FASTMAIN.IMP_TAB_RECORDS  REFERENCING  NEW AS NEW_KEY  FOR EACH ROW  MODE DB2SQL 
  8. BEGIN ATOMIC
  9. --
  10. DECLARE proc_pointer_from INTEGER DEFAULT 0;
  11. DECLARE proc_pointer_to INTEGER DEFAULT 0;
  12. DECLARE proc_pointer_last INTEGER DEFAULT 0;
  13. DECLARE proc_pointer_incr INTEGER DEFAULT 0;
  14. --
  15.  
  16. --
  17. 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');
  18. --
  19.  
  20. --
  21. SET proc_pointer_last=proc_pointer_last+proc_pointer_incr;
  22. IF proc_pointer_last>proc_pointer_to THEN
  23. SET proc_pointer_last=proc_pointer_from;
  24. END IF;
  25. --
  26.  
  27. --
  28. UPDATE pointer SET pointer_last=proc_pointer_last WHERE pointer_id='IMP001';
  29. --
  30.  
  31. --
  32. SET NEW_KEY.IMPTR_KEY=proc_pointer_last;
  33. --
  34.  
  35. END^
  36. 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

Newbie
 
Join Date: May 2008
Posts: 9
#2: Nov 7 '08

re: Problems with a simple Trigger :-(


Can you paste the error message here. So that it would become easy to identify the problem
Reply