# Database Discussions > IBM DB2 >  Sql0746n

## salman83

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.

----------

