473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creation Trigger with variables

Hello,

I try to create this trigger:

Expand|Select|Wrap|Line Numbers
  1. CREATE TRIGGER TW_OPERATOR_DELETE
  2.     AFTER DELETE ON secadm.operateur 
  3.     REFERENCING OLD AS oldOperator
  4.     FOR EACH ROW
  5.     BEGIN ATOMIC
  6.         DECLARE old_uref char(8);
  7.         DECLARE old_created timestamp;
  8.         DECLARE old_modified timestamp;
  9.         DECLARE old_version smallint;
  10.         DECLARE old_author varchar(8);
  11.         DECLARE old_status smallint;
  12.         DECLARE old_teleworking_type smallint;
  13.         DECLARE old_note_id bigint;
  14.  
  15.         SELECT operateur_uref, created, modified, version, author, status, 
  16.         teleworking_type, note_id INTO old_uref, old_created, old_modified, 
  17.         old_version, old_author, old_status, old_teleworking_type, old_note_id 
  18.         FROM material.operator_extended WHERE operateur_uref = oldOperator.uref;
  19.  
  20.         INSERT INTO material.operator_extended_versioned (operateur_uref,
  21.         created, modified, deleted, version, author, status, teleworking_type,
  22.         note_id) VALUES (old_uref, old_created, old_modified, current timestamp, 
  23.         old_version, old_author, old_status, old_teleworking_type, old_note_id);
  24.  
  25.         DELETE FROM material.operator_extended WHERE operateur_uref = old_uref;
  26.     END
But I have this error => An unexpected token "old_uref" was found following "g_type, note_id INTO". Expected tokens may include: "<space>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.7.85

And I don't found why.
Mar 5 '14 #1
1 2040
Anas Mosaad
185 128KB
I can see that you are trying to implement versioning to your operators table. If you are using DB2 10.1 you can use system period tables to implement this seamlessly by DB2 system.

If you still need to do this your own, you can call a procedure that does whatever you want.
May 19 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

181
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 ...
4
by: Pecos Bill | last post by:
Salve, non riesco a disabilitare un trigger su sqlserver nè da query analyzer, nè da enterprise manager. In pratica tal cosa riuscivo a farla in Oracle con TOAD, mentre qui non riesco. Mi...
6
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
7
by: ZRexRider | last post by:
Hi, I have trigger that enforces the creation of a sortorder that is always 1 digit higher than the current highest on Inserts. This trigger works great if I add one row at a time so I think...
6
by: Mary | last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger" table containing numerous triggers - each of which is activated by an UPDATE to a different column of this "trigger" table. When...
5
by: William of Ockham | last post by:
Hi, I was asked to recreate a new clean database for our developers because the current one they use is not entirely up to date. So I created a new database and I run into the followin strange...
8
by: Frank van Vugt | last post by:
Hi, If during a transaction a number of deferred triggers are fired, what will be their execution order upon the commit? Will they be executed in order of firing or alfabetically or...
23
by: Frank Millman | last post by:
Hi all I have a small problem. I have come up with a solution, but I don't know if it is a) safe, and b) optimal. I have a class with a number of attributes, but for various reasons I cannot...
6
by: Helmut Giese | last post by:
Hello out there, I am new to JS so please bear with me. I am tasked to investigate, whether it is feasible to port one of our applications from Tcl to JS - the idea being to write a program to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.