Error: calling the procedure in a function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradhab2
    New Member
    • Oct 2012
    • 1

    Error: calling the procedure in a function

    Error:
    (specific name "SQL12101608103 2000") is defined with the MODIFIES SQL DATA option, which is not valid in the context where the routine is invoked. SQLSTATE=51034

    Procedure:
    Code:
    CREATE PROCEDURE test_proc (IN p1 INT, OUT p3 INT)
    		LANGUAGE SQL
     		BEGIN
     		  		 SET p3 = 2 * p1;
     		END
    -----------------
    Function:
    Code:
    CREATE FUNCTION test_func(v_1 int) RETURNS varchar(1000)
    LANGUAGE SQL
     MODIFIES SQL DATA
    BEGIN 
    DECLARE v_2 varchar(1000);
    call test_proc(v_1,v_2);
    return v_2;
    END
    @
    -----------

    select ccdradm.test_fu nc(5) from sysibm.dual

    ------------
    Error:
    51034(-740)[IBM][CLI Driver][DB2/SUN64] SQL0740N Routine "TEST_FUNC" (specific name "SQL12101608305 1700") is defined with the MODIFIES SQL DATA option, which is not valid in the context where the routine is invoked. SQLSTATE=51034
    (0.58 secs)



    Pls suggest to solve the issue
    Last edited by Meetee; Oct 16 '12, 10:57 AM. Reason: please add code tags <code/> around your code
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    This is from the DB2 documentation.

    Explanation:
    The routine routine-name (specific name specific-name ) is defined with MODIFIES SQL DATA and is therefore not allowed in:

    •a BEFORE trigger
    •a correlated subquery
    •a search-condition (such as a WHERE clause or check constraint)

    User Response:
    Ensure that routine resolution resolved to the desired routine. Remove the routine from the failing statement or redefine the routine with an SQL access indicator other than MODIFIES SQL DATA.

    sqlcode : -740

    sqlstate : 51034
    I would choose the second option of the available user responses as I don't see that you have anything that modifies sql data anyways.

    Comment

    Working...