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

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','SUBSELECT,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(ROW#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBSEL')
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#,ITEM_NAME,ITEM_COUNT) AS
(SELECT MAX_ROW#,ITEMNAME AS ITEM_NAME,count(*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(QUERY_DESCR)) - LENGTH(REPLACE(STRIP (QUERY_DESCR),
ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_ROW#)
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(ROW#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBSEL')
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#,ITEM_NAME,ITEM_COUNT) AS
(SELECT MAX_ROW#,ITEMNAME AS ITEM_NAME,count(*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(QUERY_DESCR)) - LENGTH(REPLACE(STRIP
(QUERY_DESCR),ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_ROW#)
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','SUBSELECT,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_REFERENCE".

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 3718
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','SUBSELECT,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(ROW#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBSEL')
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#,ITEM_NAME,ITEM_COUNT) AS
(SELECT MAX_ROW#,ITEMNAME AS ITEM_NAME,count(*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(QUERY_DESCR)) - LENGTH(REPLACE(STRIP (QUERY_DESCR),
ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_ROW#)
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(ROW#) AS LAST_GROUP_NUM
FROM CROSS_REFERENCE
WHERE KEY_WORD IN('JOIN','SUBSEL')
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#,ITEM_NAME,ITEM_COUNT) AS
(SELECT MAX_ROW#,ITEMNAME AS ITEM_NAME,count(*) AS QTY_USED
FROM T1,T2
WHERE (LENGTH(STRIP(QUERY_DESCR)) - LENGTH(REPLACE(STRIP
(QUERY_DESCR),ITEMNAME,''))) 0
GROUP BY ITEMNAME,MAX_ROW#)
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','SUBSELECT,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_REFERENCE".

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 #2
Never mind. I was able to resolve this problem by using udf + sp
execute_immediate 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
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...
2
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...
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...
1
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....
6
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,...
1
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...
6
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
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...
2
by: gabielmatos | last post by:
this is my query; string NPI = fields.GetValue(0).ToString(); string EntiType = fields.GetValue(1).ToString(); string ProvLastNameLegal = ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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.