473,395 Members | 1,905 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.

RRN in trigger.

Hi all,
I am currently working in a scenario where, I had to write trigger(insert,update and delete) for a certain table in DB2 database(DB2 for i V5R4).
The table have no primary key, but I need one to identify the records.
The application is legacy and hence I cannot expect the client to change the DB structure.
Hence I tried to use RRN( Relative Record Number) in my trigger.
Here is the trigger I wrote.
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE TRIGGER "CMB"."CASPR_I" 
  3.     AFTER INSERT ON "CMB"."CASPR"
  4.     REFERENCING  NEW AS NEW_ROW
  5.     FOR EACH ROW MODE DB2SQL
  6. BEGIN ATOMIC
  7. DECLARE RID DECIMAL(15,0);
  8. SET RID=NEW_ROW.RRN("CMB"."CASPR");
  9.      INSERT INTO "CMB"."AS400_CASPR" (ROW_ID,PREFIX,GEN_ACTION,GEN_DATE)
  10.          VALUES(RID,NEW_ROW.PREFIX,'INSERT',CURRENT DATE);
  11. END
  12.  
I read that RRN is stored in static section of trigger buffer, but I couldn't figure out how to use it.
I need some serious help.

Regards.
Sep 2 '13 #1
2 1957
I think this PDF could help to fix it http://publib.boulder.ibm.com/infoce.../dbp/rbafo.pdf
Sep 2 '13 #2
Mr. Kumar,
Thanks for you reply.
I had seen the document earlier, but it doesn't specify any way to access the RRN. Please share any examples,if any.
Regards.
Sep 2 '13 #3

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

Similar topics

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...
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...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
1
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...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
7
by: Shane | last post by:
I have been instructed to write a trigger that effectively acts as a foreign key. The point (I think) is to get me used to writing triggers that dont use the primary key(s) I have created the...
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'...
0
by: David Robertson | last post by:
Hello, I have a request that I thought was straightforward and would be fairly simple. After many hours of research and trying various triggers, procedures and variables, I have not been able to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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.