473,404 Members | 2,187 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,404 software developers and data experts.

Help with a trigger

[8.2.1 UDB on linux]

I've got two tables, one holding the current price of a product, and
one to hold all prior versions;

CREATE TABLE product_pricing (product varchar(10), price decimal (9,
2), last_changed date);
CREATE TABLE product_pricing_history (product varchar(10), price
decimal (9, 2), start date, end date);

Every time update the price in the product_pricing table, I want the
old value to be inserted into the product_pricing_history table. So I
thought this would work:

CREATE TRIGGER price_history_tr
NO CASCADE BEFORE UPDATE OF price ON product_pricing
REFERENCING OLD as oldprice
FOR EACH ROW
BEGIN ATOMIC
INSERT INTO product_pricing_history (product, start, end, price)
VALUES (oldprice.product, oldprice.last_changed, current date,
oldprice.price);
END

However, I get back SQLSTATE 42987: The statement is not allowed in a
procedure or trigger.

Am I doing something blatantly wrong here, or should I take this up
with IBM Support? Being new to triggers, I'm working from the online
doco, and I can't see what in particular I might be doing that's wrong
(
http://publib.boulder.ibm.com/infoce...n/r0000931.htm
)

Nov 12 '05 #1
2 1631
Hi James,

James Foreman wrote:
CREATE TRIGGER price_history_tr
NO CASCADE BEFORE UPDATE OF price ON product_pricing
REFERENCING OLD as oldprice
FOR EACH ROW
BEGIN ATOMIC
INSERT INTO product_pricing_history (product, start, end, price)
VALUES (oldprice.product, oldprice.last_changed, current date,
oldprice.price);
END

However, I get back SQLSTATE 42987: The statement is not allowed in a
procedure or trigger.


Afair, inserting data in other tables is not allowed in DB2 before
triggers. Try using an "after update" trigger, that should work.

hth,
Benjamin
--
11.+12.11.2005: SFSCon 2005
see http://www.sfscon.it
Nov 12 '05 #2
Thanks for that - all sorted

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Curtis Gilchrist | last post by:
I'm trying my hand at triggers and it doesn't seem to be working for me. I have a very simple database that consists of one table: Employees. I want to create a trigger that will limit the...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
11
by: Jules Alberts | last post by:
Hello everybody, Someone helped me earlier with this TCL trigger function: create or replace function tlow() returns trigger as ' set NEW($1) return ' language 'pltcl'; I use it to force...
11
by: ricolee99 | last post by:
Hi everyone, I'm trying to invoke my .exe application from a remote server. Here is the code: ManagementClass processClass = new ManagementClass ("\\\\" +"RemoteServerName" +...
4
by: SUKRU | last post by:
Hello everybody. Unfortunately I am pretty new to sql-server 2000 I need some help with a Trigger I created. I created a trigger witch takes the id of the affected row and does a update on a...
0
by: Michael L | last post by:
Hi Guys(I apologize for the lengty post - Im trying to explain it as best i can) I've been cracking my head on this one for the past 24+ hours and i have tried creating the function in ten...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
3
by: Sam Durai | last post by:
Need help to write a trigger according to the following business requirement. This on DB2 UDB V8.2 / AIX 5.3 Whenever a 100th record is inserted into my 'ACCOUNT' table with a particular...
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
3
by: faathir88 | last post by:
i'd like to insert lots of data n its hard to determine which field would be the primary key, coz all of them almost similar. So, i decided to use sequence for its PK by using trigger here's the...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.