473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help: Insert generating -803 in Trigger

Hi Everebody:
I have a table:

CREATE TABLE CROSS_REFERENCE
(ROW# INTEGER NOT NULL
,KEY_WORD CHAR(16) NOT NULL
,QUERY_DESCR VARCHAR(330) NOT NULL
,PRIMARY KEY (ROW#,KEY_WORD) );

It is a cross reference table to my CATALOG Table based on key words.
I am trying to create a tigger. Every time when i insert a row in CATALOG
Table corresponding
rows will be inserted in Cross referenvce table depending of key words.
I tested trigger body first:

I want to Insert in Catalog table following row:
INSERT INTO NEW_CATALOG
VALUES
('SUBSL','SUBSE LECT,EXIST,NOT EXIST ','DB2 QUERY',13,'HOW TO TRANSFER
JOIN IN CORELLATED OR NOT CORRELATED SUBQUERY');

There are 2 key words in this row: JOIN and SUBQUERY.
Last keys in groups before testing trigger body:
SELECT KEY_WORD,MAX(RO W#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBS EL')
GROUP BY KEY_WORD;

KEY_WORD LAST_GROUP_NUM
---------------- --------------------------------------
JOIN 64
SUBSEL 13

Trigger body:
INSERT INTO CROSS_REFERENCE
WITH T1 (QUERY_DESCR) AS
(VALUES( 'HOW TRANSFER SUBSELECT IN JOIN')),
T2(ItemName,MAX _ROW#) AS
(SELECT DISTINCT STRIP(KEY_WORD) ,MAX(ROW#)
FROM CROSS_REFERENCE
GROUP BY STRIP(KEY_WORD) ),
T3(MAX_ROW#,ITE M_NAME,ITEM_COU NT) AS
(SELECT MAX_ROW#,ITEMNA ME AS ITEM_NAME,count (*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(Q UERY_DESCR)) - LENGTH(REPLACE( STRIP (QUERY_DESCR),
ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_RO W#)
SELECT MAX_ROW# + 1,ITEM_NAME ,'SUBSL' ||' ' || CHAR(13)||' '||QUERY_DESCR
FROM T3,T1;

DB20000I The SQL command completed successfully.

Same query After succsesfull INSERT:

SELECT KEY_WORD,MAX(RO W#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBS EL')
GROUP BY KEY_WORD;

KEY_WORD LAST_GROUP_NUM
---------------------- ----------------------------------
JOIN 65
SUBSEL 14

Now i am tesing with the Trigger:
CREATE TRIGGER CROSS_REFF_TRIG
AFTER INSERT
ON NEW_CATALOG
REFERENCING NEW AS n
FOR EACH ROW
MODE DB2SQL
INSERT INTO CROSS_REFERENCE
WITH T1 (QUERY_DESCR) AS
(SELECT n.QUERY_DESC FROM NEW_CATALOG),
T2(ItemName,MAX _ROW#) AS
(SELECT DISTINCT STRIP(KEY_WORD) ,MAX(ROW#)
FROM CROSS_REFERENCE
GROUP BY STRIP(KEY_WORD) ),
T3(MAX_ROW#,ITE M_NAME,ITEM_COU NT) AS
(SELECT MAX_ROW#,ITEMNA ME AS ITEM_NAME,count (*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(Q UERY_DESCR)) - LENGTH(REPLACE( STRIP
(QUERY_DESCR),I TEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_RO W#)
SELECT MAX_ROW# + 1,ITEM_NAME ,n.GROUP_ID ||' ' ||CHAR(QUERY#)| |'
'||QUERY_DESCR FROM T3,T1;

DB20000I The SQL command completed successfully.

trigger event:

INSERT INTO NEW_CATALOG
VALUES
('SUBSL','SUBSE LECT,EXIST,NOT EXIST ','DB2 QUERY',14
,'HOW TO TRANSFER JOIN IN CORELLATED OR NOT CORRELATED SUBQUERY');

SQLCODE "-803", SQLSTATE "23505" and message tokens "1|LENY.CROSS_R EFERENCE".

SQLSTATE=09000
Why -803. MAX_ROW# + 1 in this query always create unique key.
Thank's in advance Leny.G

--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200808/1

Aug 24 '08 #1
2 3747
I Just added Fetch first 1 row only to the trigger and it is working,
inserting only one row.
But i need more then one insert. Does it mean I cannot have multible inserts
in the trigger?

lenygold wrote:
>Hi Everebody:
I have a table:

CREATE TABLE CROSS_REFERENCE
(ROW# INTEGER NOT NULL
,KEY_WORD CHAR(16) NOT NULL
,QUERY_DESCR VARCHAR(330) NOT NULL
,PRIMARY KEY (ROW#,KEY_WORD) );

It is a cross reference table to my CATALOG Table based on key words.
I am trying to create a tigger. Every time when i insert a row in CATALOG
Table corresponding
rows will be inserted in Cross referenvce table depending of key words.
I tested trigger body first:

I want to Insert in Catalog table following row:
INSERT INTO NEW_CATALOG
VALUES
('SUBSL','SUBS ELECT,EXIST,NOT EXIST ','DB2 QUERY',13,'HOW TO TRANSFER
JOIN IN CORELLATED OR NOT CORRELATED SUBQUERY');

There are 2 key words in this row: JOIN and SUBQUERY.
Last keys in groups before testing trigger body:
SELECT KEY_WORD,MAX(RO W#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBS EL')
GROUP BY KEY_WORD;

KEY_WORD LAST_GROUP_NUM
---------------- --------------------------------------
JOIN 64
SUBSEL 13

Trigger body:
INSERT INTO CROSS_REFERENCE
WITH T1 (QUERY_DESCR) AS
(VALUES( 'HOW TRANSFER SUBSELECT IN JOIN')),
T2(ItemName,MAX _ROW#) AS
(SELECT DISTINCT STRIP(KEY_WORD) ,MAX(ROW#)
FROM CROSS_REFERENCE
GROUP BY STRIP(KEY_WORD) ),
T3(MAX_ROW#,ITE M_NAME,ITEM_COU NT) AS
(SELECT MAX_ROW#,ITEMNA ME AS ITEM_NAME,count (*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(Q UERY_DESCR)) - LENGTH(REPLACE( STRIP (QUERY_DESCR),
ITEMNAME,'') )) 0
GROUP BY ITEMNAME,MAX_RO W#)
SELECT MAX_ROW# + 1,ITEM_NAME ,'SUBSL' ||' ' || CHAR(13)||' '||QUERY_DESCR
FROM T3,T1;

DB20000I The SQL command completed successfully.

Same query After succsesfull INSERT:

SELECT KEY_WORD,MAX(RO W#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBS EL')
GROUP BY KEY_WORD;

KEY_WORD LAST_GROUP_NUM
---------------------- ----------------------------------
JOIN 65
SUBSEL 14

Now i am tesing with the Trigger:

CREATE TRIGGER CROSS_REFF_TRIG
AFTER INSERT
ON NEW_CATALOG
REFERENCING NEW AS n
FOR EACH ROW
MODE DB2SQL
INSERT INTO CROSS_REFERENCE
WITH T1 (QUERY_DESCR) AS
(SELECT n.QUERY_DESC FROM NEW_CATALOG),
T2(ItemName,MAX _ROW#) AS
(SELECT DISTINCT STRIP(KEY_WORD) ,MAX(ROW#)
FROM CROSS_REFERENCE
GROUP BY STRIP(KEY_WORD) ),
T3(MAX_ROW#,ITE M_NAME,ITEM_COU NT) AS
(SELECT MAX_ROW#,ITEMNA ME AS ITEM_NAME,count (*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(Q UERY_DESCR)) - LENGTH(REPLACE( STRIP
(QUERY_DESCR), ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_RO W#)
SELECT MAX_ROW# + 1,ITEM_NAME ,n.GROUP_ID ||' ' ||CHAR(QUERY#)| |'
'||QUERY_DES CR FROM T3,T1;

DB20000I The SQL command completed successfully.

trigger event:

INSERT INTO NEW_CATALOG
VALUES
('SUBSL','SUBS ELECT,EXIST,NOT EXIST ','DB2 QUERY',14
,'HOW TO TRANSFER JOIN IN CORELLATED OR NOT CORRELATED SUBQUERY');

SQLCODE "-803", SQLSTATE "23505" and message tokens "1|LENY.CROSS_R EFERENCE".

SQLSTATE=090 00
Why -803. MAX_ROW# + 1 in this query always create unique key.
Thank's in advance Leny.G
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200808/1

Aug 24 '08 #2
Never mind. I was able to resolve this problem by using udf + sp
execute_immedia te and
execute this insert dynamicly.

lenygold wrote:
>I Just added Fetch first 1 row only to the trigger and it is working,
inserting only one row.
But i need more then one insert. Does it mean I cannot have multible inserts
in the trigger?
>>Hi Everebody:
I have a table:
[quoted text clipped - 98 lines]
>>Why -803. MAX_ROW# + 1 in this query always create unique key.
Thank's in advance Leny.G
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200808/1

Aug 25 '08 #3

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

Similar topics

7
2382
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help me. This was inspired by Exercise 7 and Programming Problem 8 in Chapter 3 of our text. I have done Exercise 7 for you: Below you will find the ADT specification for a string of characters. It represents slightly more that a minimal string...
2
17746
by: Amanda | last post by:
From a guy in Microsoft newsgroups: | In *comp.databases.ibm-db2* there are always IBM guys | from the Toronto labs on line.Post with the | -for the love of god please help- | line and I'm sure you'll get their attention. | Their usually very good:) So here's my transplanted post ==========================================
4
1955
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 other table with that ID. The trigger works fine with one affected row. But when there are more then one rows affected, i get an error. I found out that SQL-server does not support row-level triggers. I should probable make my own cursor and...
1
6202
by: abhi81 | last post by:
Hello All, I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp. Insert and Update trigger work fine when i have only one of them defined. However when I have all the 3 triggers in place and when i try to fire a insert query on the statement. It triggers both insert and update trigger at the same time and...
6
3310
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID, EmpName,DeptID,DateOfJoin, Sal, Addr) Finance (EmpID, Sal) Club (Clubname, EmpID, Fee, DateOfJoin) Leave (EmpID, Date) Department (DeptID, DeptName, NoOfEmployees)...
1
1165
by: TanmayQuery | last post by:
I have written a sql procedure, i want to pass delared variable @cnt in line131,char24 below is the PL Code: CREATE PROCEDURE PL @dt varchar(10), @stock as bit --1/true for updated and 0/false for previous executed data AS set dateformat dmy set nocount on
6
1607
by: backups2007 | last post by:
Here's my code. For some reason, it's not working. Please help... Thank you. <? $so_no=$_POST; //customer type $ctype=$_POST; //customer info $cust_id=$_POST; $walkin_id=$_POST;
3
1645
by: backups2007 | last post by:
Here'es my code. I double checked it and I can't seem to find any reason why it won't work. Or maybe I just missed something. Please help. Thanks. If you have any suggestion on how I can improve this code, please post your them. //inserting so if($cust_id!="") { $query_dealer = mysql_query("INSERT INTO service_order (so_no, cust_id, prod_id, qty, purchase_date, invoice_no, date_arrived, time_arrived, date_started, time_started,...
2
1794
by: gabielmatos | last post by:
this is my query; string NPI = fields.GetValue(0).ToString(); string EntiType = fields.GetValue(1).ToString(); string ProvLastNameLegal = fields.GetValue(5).ToString(); string ProvFirsName = fields.GetValue(6).ToString(); string ProvMiddName = fields.GetValue(7).ToString(); string PromNamePref = fields.GetValue(8).ToString(); ...
0
8384
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
8302
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
8820
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
8601
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
7314
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.