If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Sql0746n

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-10, 08:37
salman83 salman83 is offline
Registered User
 
Join Date: Jan 2010
Posts: 4
Sql0746n

Hi,

I have a function which is calling another function.

Both functions are declared with MODIFIES SQL DATA.

When executing the function, I receive an error message.

SQL0746N Routine "FUNC2" (specific name "SQL101118132755900") violated nested SQL statement rules when attempting to perform operation "MODIFY" on table "T2".


Functions
========

CREATE OR REPLACE FUNCTION FUNC1(v1 INTEGER, v2 INTEGER)
RETURNS INTEGER
MODIFIES SQL DATA
BEGIN

DECLARE vId INTEGER;
DECLARE Temp INTEGER;

-- Copy all the fields of the compound

SELECT ID INTO vId FROM FINAL TABLE
(INSERT INTO T1(
Name)
SELECT Name
FROM T1
WHERE Id = v1);

SET Temp = FUNC2(vId);

RETURN vId;
END \





CREATE OR REPLACE FUNCTION FUNC2(v1 INTEGER)
RETURNS INTEGER
MODIFIES SQL DATA
BEGIN

DECLARE vId INTEGER;

-- Copy all the fields of the compound

SELECT ID INTO vId FROM FINAL TABLE
(INSERT INTO T2(
Name)
SELECT Name
FROM T2
WHERE Id = v1);

RETURN vId;
END \





Kindly is there any way to get rid of this problem.

Thanks in advance.

Regards.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On