473,799 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

V8.2 Trigger - NEXTVAL FOR seq -- behaviour change?

Hi,

Having just tested our database on V8.2 we get the following apparent
incompatibility .

A Trigger conatains the following line

CREATE TRIGGER JABS.AU_CHNG_EN QUIRYITM
AFTER UPDATE OF
..
..
SET v_change_notes_ oid = NEXTVAL FOR JABS.CHANGE_NOT ES_OID;
..

The trigger still CREATEs OK, but always now gives the following
runtime error
after an update?

SQL0723N An error occurred in a triggered SQL statement in trigger
"JABS.AU_CHNG_E NQUIRYITM". Information returned for the error
includes
SQLCODE "-348", SQLSTATE "428F9" and message tokens "NEXTVAL FOR
JABS.CHANGE_NOT ES_OID". SQLSTATE=09000

Do we need to change how this is coded or is this a new V8.2 Bug
(we were on V8.1.6 before) ?

Thanks.

Paul.
Nov 12 '05 #1
4 4698
I can't repro.. can you provide a full script to repro?

db2 => connect to test;

Database Connection Information

Database server = DB2/NT 8.2.0
SQL authorization ID = SRIELAU
Local database alias = TEST

db2 => create table ttt(c1 int);
DB20000I The SQL command completed successfully.
db2 => create sequence s1;
DB20000I The SQL command completed successfully.
db2 => create trigger trg1 after update on ttt for each row begin atomic
db2 (cont.) => declare a int; --
db2 (cont.) => set a = nextval for s1; --
db2 (cont.) => end;
DB20000I The SQL command completed successfully.
db2 => insert into ttt values 1;
DB20000I The SQL command completed successfully.
db2 => update ttt set c1 = c1 + 1;
DB20000I The SQL command completed successfully.
db2 =>
Nov 12 '05 #2
Hi,

I have tried to workaround this problem by doing the following.

I have taken the trigger body and created a Stored Procedure and now
simply CALL the SP from the trigger.
- I wanted to do this anyway for performance, i.e the trigger body
was causing INSERTS and UPDATES to take several seconds to
compile.
and I've been waiting for V8.2 before doing this.

However, this seems to have thrown up another (bigger) issue which I
was hoping wouldn't be the case when calling SPs from triggers.

The inserts performed by the statements in the SP (identical to how
they
were in the Trigger) now cause a SQLCODE -746 !!!
i.e It is not allowed to read the original table that fired the
trigger from the SP. Not that I am explictly doing this, but the
table I am inserting into has an RI FK constraint back onto the
original table.

So, my general question is ...

It appears that the new CALL SP from a trigger, doesn't give the
statements in the SP the same 'context' as they have when they are in
the trigger body ?

Is this intended behaviour, or is there an option etc I can set so
that the SP
statements perform exactly as if they were in the trigger body?
- NB. I have tried coding them static & dynamic in the SP with no
difference.

(Also, it appears that a SNAPSHOT_APPL_I NFO() returns NULL from within
the called SP too - which it doesn't if the SP is called directly
rather than via
the trigger?)

Thanks.

Paul.
Nov 12 '05 #3
Paul,

See my very recent post on that topic.
DB2 wrt. the runtime error you observe is working as designed.
I'm currently canvasing feedback on whether it is working as desired :-)

Cheers
Serge
Nov 12 '05 #4
Serge Rielau <sr*****@ca.ibm .com> wrote in message news:<2t******* ******@uni-berlin.de>...
Paul,

See my very recent post on that topic.
DB2 wrt. the runtime error you observe is working as designed.
I'm currently canvasing feedback on whether it is working as desired :-)

Cheers
Serge

I believe my trigger/sp issue is the same/similar to Paul's.
I get the same -746 error. It appears the behaviour of the sql
statments in the trigger are dissimilar the behaviour of the sql
statments in the procedure.
I have abandoned the proc and have proceeded with the trigger until I
can figure out the problem.
Nov 12 '05 #5

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

Similar topics

1
4595
by: Darren | last post by:
Hello, I have some 'CREATE TRIGGER' definitions that work when cut/pasted into SQL*Plus worksheet and execute separately but fail with a 'trigger created with compilation errors' when executed at the same time. Neither works at all under Solaris sqlplus. Does anyone see what the problem is? create or replace trigger aut_itri
0
4116
by: Sean Utt | last post by:
Table "grps" Column | Type | Modifiers -------------+-----------------------------+-------------------------------- --------------------- grpsid | integer | not null default nextval('"grps_grpsid_seq"'::text) grpsname | text | not null memberofgrp | integer | not null default -1 dateadded | timestamp without time zone |...
2
2660
by: ezra epstein | last post by:
Hi, I've got a table: <code language="SQL"> CREATE TABLE "common"."dynamic_enum" ( "pk_id" integer DEFAULT nextval('"common"."pw_seq"') , "enum_type" common.non_empty_name
0
2045
by: Yogesh | last post by:
Hello Everyone I have to create Oracle tables in my application on the fly, which have an Autonumber field. So, everytime I create a table, I have to create a corresponding sequence and trigger for the table. Let's consider the following simple example: ------------------- create table testTable(id NUMBER(10) PRIMARY KEY, name VARCHAR(20));
3
3433
by: beer | last post by:
Hello All I'm running 7.3.4-1 on a RH9 box. I'm having a problem with a trigger that seems to execute without actually performing the update that it should. The update returns true everytime however if it is the first time that the trigger executes on a given row, the column is not updated. The column is updated correctly on subsequent calls. Here is the code:
5
3968
by: Peter Erickson | last post by:
I am running postgresql 7.4.2 and having problems creating a trigger function properly. I keep getting the following error: ERROR: OLD used in query that is not in rule I have a table called journal_entries with a foreign key to a table called journals. When a entry is added to journal_entries, I am trying to get it to update the 'mtime' field of the corresponding entry in the journals table.
1
2214
by: deepdata | last post by:
Hi, I am creating a trigger in DB2 express version. When i use the following syntax to create trigger CREATE TRIGGER USER_PK_TRIGGER BEFORE INSERT On users REFERENCING NEW As N FOR EACH ROW
1
21063
by: filip1150 | last post by:
I'm trying to find if there is any performance diference between explicitly using a sequence in the insert statement to generate values for a column and doing this in an insert trigger. I noticed that th eaccess plan for the 2 situations is quite different. For the case where the trigger is in place, the optimizer applies 2 extra residual predicates. Can anybody explain where the differences come from? Also, for real life situations,...
2
3371
by: wugon.net | last post by:
Problem: after inser trigger encounter error sql0348 Env:db2 v8 + fp 13 + win xp Description: we build two after insert triggers DB2.TRG1, DB2.TRG2 on base table DB2.TEST1, insert data into DB2.TEST1 encounter error sql0348 but we re-create trigger DB2.TRG2 before DB2.TRG1 and re-insert data
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.