Connecting Tech Pros Worldwide Help | Site Map

DB21034E with triggers

  #1  
Old October 27th, 2008, 01:45 PM
=?ISO-8859-2?Q?Gregor_Kova=E8?=
Guest
 
Posts: n/a
Hi!

My trigger looks like this:

CREATE TRIGGER REVIZIJA.T_1_AU AFTER UPDATE ON TABLE1
REFERENCING OLD O
NEW N
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC

DECLARE OLD_VALUE VARCHAR(120);
DECLARE NEW_VALUE VARCHAR(120);

SET OLD_VALUE = SUBSTR(O.VALUE, 1, 120);
SET NEW_VALUE = SUBSTR(N.VALUE, 1, 120);

INSERT INTO LOG.TABLE (ID, OLD, NEW) VALUES (NEXTVAL FOR TABLE_SEQ,
OLD_VALUE, NEW_VALUE);
END

It is true that VALUE column in table TABLE1is defined as
VARCHAR(30000). Is there any way to make this trigger compile?

Best regards,
Kovi

--

____________________________
|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
  #2  
Old October 28th, 2008, 05:15 PM
Serge Rielau
Guest
 
Posts: n/a

re: DB21034E with triggers


Gregor Kovač wrote:
Quote:
Hi!
>
My trigger looks like this:
>
CREATE TRIGGER REVIZIJA.T_1_AU AFTER UPDATE ON TABLE1
REFERENCING OLD O
NEW N
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
>
DECLARE OLD_VALUE VARCHAR(120);
DECLARE NEW_VALUE VARCHAR(120);
>
SET OLD_VALUE = SUBSTR(O.VALUE, 1, 120);
SET NEW_VALUE = SUBSTR(N.VALUE, 1, 120);
>
INSERT INTO LOG.TABLE (ID, OLD, NEW) VALUES (NEXTVAL FOR TABLE_SEQ,
OLD_VALUE, NEW_VALUE);
END
>
It is true that VALUE column in table TABLE1is defined as
VARCHAR(30000). Is there any way to make this trigger compile?
I think you may be stuck here. DB2 needs to be able to build a temp with
both the old and new value.

VARCHAR(32000) is a lot of text....

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
  #3  
Old October 29th, 2008, 07:35 AM
=?ISO-8859-2?Q?Gregor_Kova=E8?=
Guest
 
Posts: n/a

re: DB21034E with triggers


Hi!

Yes, a lot of text. It is just that I'm building sort of an archiving
system and on update I'd need new and old values.
Can I solve this some other way?

Best regards,
Kovi

Serge Rielau pravi:
Quote:
Gregor Kovač wrote:
Quote:
>Hi!
>>
>My trigger looks like this:
>>
>CREATE TRIGGER REVIZIJA.T_1_AU AFTER UPDATE ON TABLE1
>REFERENCING OLD O
> NEW N
>FOR EACH ROW MODE DB2SQL
>BEGIN ATOMIC
>>
>DECLARE OLD_VALUE VARCHAR(120);
>DECLARE NEW_VALUE VARCHAR(120);
>>
>SET OLD_VALUE = SUBSTR(O.VALUE, 1, 120);
>SET NEW_VALUE = SUBSTR(N.VALUE, 1, 120);
>>
>INSERT INTO LOG.TABLE (ID, OLD, NEW) VALUES (NEXTVAL FOR TABLE_SEQ,
>OLD_VALUE, NEW_VALUE);
>END
>>
>It is true that VALUE column in table TABLE1is defined as
>VARCHAR(30000). Is there any way to make this trigger compile?
I think you may be stuck here. DB2 needs to be able to build a temp
with both the old and new value.
>
VARCHAR(32000) is a lot of text....
>
--
____________________________
|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
  #4  
Old October 30th, 2008, 02:35 AM
Serge Rielau
Guest
 
Posts: n/a

re: DB21034E with triggers


Gregor Kovač wrote:
Quote:
Hi!
>
Yes, a lot of text. It is just that I'm building sort of an archiving
system and on update I'd need new and old values.
Can I solve this some other way?
Why do you need to store both before and after image?


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
  #5  
Old October 30th, 2008, 08:55 AM
=?ISO-8859-2?Q?Gregor_Kova=E8?=
Guest
 
Posts: n/a

re: DB21034E with triggers


Unfortunately, yes.

Best regards,
Kovi

Serge Rielau pravi:
Quote:
Gregor Kovač wrote:
Quote:
>Hi!
>>
>Yes, a lot of text. It is just that I'm building sort of an archiving
>system and on update I'd need new and old values.
>Can I solve this some other way?
Why do you need to store both before and after image?
>
>
--
____________________________
|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Should db2 allow this table to be created Bernard Dhooghe answers 7 July 18th, 2006 11:25 AM
Trigger syntax ? problem PA answers 3 November 12th, 2005 10:46 AM
Calling stored procedure in a trigger Prem via DBMonster.com answers 2 November 12th, 2005 10:36 AM
SET Integrity Exception Table - How to use maricel answers 4 November 12th, 2005 06:51 AM