473,387 Members | 1,465 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,387 software developers and data experts.

Calling stored procedure in a trigger

hi,
i am working on a migration project from Oracle to db2 8.1. i was able to
migrate the stored procedures and functions in oracle to db2 with the help
of the migration tool kit.
now finally when i came to the trigger i am having problems. the trigger is
not getting compiled. Triggers call the stored procedures and functions in
them.

For example.
--the values passed in the parameter are all varchar only

CREATE TRIGGER t_content NO CASCADE BEFORE DELETE ON TCAT_CONTENT_COLLATERAL
REFERENCING OLD AS OLD FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL sp_delete ('Category', old.category_id, old.collateral_id );
CALL sp_update ('DCS_CATEGORY', 'category_id', old.category_id);
END;

The error received was.

DB21034E The command was processed as an SQL statement because it was not
avalid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "CALL sp_delete" was found
following "DB2SQL BEGIN ATOMIC". Expected tokens may
include:"<compound_return>". LINE NUMBER=1. SQLSTATE=42601

Thanx in advance
mail to pj*@srasys.co.in

regards
Premnath

--
Message posted via http://www.dbmonster.com
Nov 12 '05 #1
2 4659
Prem via DBMonster.com wrote:
hi,
i am working on a migration project from Oracle to db2 8.1. i was able
to
migrate the stored procedures and functions in oracle to db2 with the help
of the migration tool kit.
now finally when i came to the trigger i am having problems. the trigger
is
not getting compiled. Triggers call the stored procedures and functions in
them.

For example.
--the values passed in the parameter are all varchar only

CREATE TRIGGER t_content NO CASCADE BEFORE DELETE ON
TCAT_CONTENT_COLLATERAL REFERENCING OLD AS OLD FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL sp_delete ('Category', old.category_id, old.collateral_id );
CALL sp_update ('DCS_CATEGORY', 'category_id', old.category_id);
END;


You might want to consider upgrading to V8.2 because CALL is supported in
triggers with that release.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
Prem via DBMonster.com wrote:
hi,
i am working on a migration project from Oracle to db2 8.1. i was able to
migrate the stored procedures and functions in oracle to db2 with the help
of the migration tool kit.
now finally when i came to the trigger i am having problems. the trigger is
not getting compiled. Triggers call the stored procedures and functions in
them.

For example.
--the values passed in the parameter are all varchar only

CREATE TRIGGER t_content NO CASCADE BEFORE DELETE ON TCAT_CONTENT_COLLATERAL
REFERENCING OLD AS OLD FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL sp_delete ('Category', old.category_id, old.collateral_id );
CALL sp_update ('DCS_CATEGORY', 'category_id', old.category_id);
END;

The error received was.

DB21034E The command was processed as an SQL statement because it was not
avalid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "CALL sp_delete" was found
following "DB2SQL BEGIN ATOMIC". Expected tokens may
include:"<compound_return>". LINE NUMBER=1. SQLSTATE=42601

Couple of problems:
1. CALL in Trigger is a DB2 V8.2 feature
2. Apparently you try to MODIFY SQL DATA in these SQL Procedures. BEFORE
TRIGGERS are not meant to mondifye SQL DATA
(i.e do UPDATE, DELETE, INSERT, MERGE)
You will need to turn this trigger into an AFTER trigger (shouldn't be a
big deal)

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

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

Similar topics

7
by: bajwa | last post by:
Hi Our SQL server has a lot of stored procedures and we want to get some cleaning up to be done. We want to delete the ones that have been not run for like 2-3 months. How exactly will i find out...
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...
3
by: Paul Reddin | last post by:
Hi, FYI & comment: We have triggers that call SPs. If the Stored Procedure is invalidated, e.g a dependent table is dropped. The SP is marked as invalid, but no error is thrown by the...
5
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
4
by: Pakna | last post by:
Hi, is there any way to call a JAVA stored procedure from a SQL Trigger? We are having difficulties with this and cannot verify whether DB2 even *has* this capability? Thank you very much....
2
by: Al Willis | last post by:
Hello, I've written an insert trigger to fill in data on 5 columns based on the key field column after a record is added to a table. The trigger works fine. But what I also want to do is to...
3
by: Goog79 | last post by:
Hi everyone, first time here, so I'm sorry if this has been covered already ages ago. :( I am trying to learn T-SQL and Stored Procedures and bought the book on these topics by Djan...
3
by: yinzara | last post by:
I have the following trigger that calls a DB2 stored procedure: DROP TRIGGER GGWU.TRI_A_MULTI_PROP@ CREATE TRIGGER GGWU.TRI_A_MULTI_PROP AFTER INSERT ON GGWU.MULTIPLIER_PROPERTY REFERENCING ...
3
by: Constantine AI | last post by:
Hi we have created a stored procedure to check the dates entered into a lease table does not overlap dates already stored for a lease. However when inserting overlapping lease dates, it allows us to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.