c***@cslucas.com.sg
2007-09-23 12:22:20 UTC
I have the following build problem with UDF calling a Stored Procedures the following. The simplified codes does the following:
CREATE FUNCTION MY_UDF(date1 DATE, date2 DATE)
RETURNS DOUBLE
LANGUAGE SQL
EXTERNAL ACTION
BEGIN ATOMIC
DECLARE out_val DOUBLE;
CALL MY_SP(date1, date2, out_val);
RETURN out_val;
END
CREATE PROCEDURE MY_SP(date1 DATE, date2 DATE, out_val DOUBLE)
LANGUAGE SQL
EXTERNAL ACTION
-- logic omitted...
-- Briefly it loops through a set of values over the date range
-- in particular tables. This is done via User Defined Table.
-- Intermediate result are organized and stored in a GLOBAL TEMPORARY
-- TABLE. This information is then further processed using UPDATES.
-- The final result is single double "out_val". Like an average.
MY_SP is working fine.
But when I try to build MY_UDF, I get a SQL0374N which suggest I add in the MODIFIES SQL DATA clause. But when I do that, I get the SQL0628N Multiple or conflicting keywords involving the "MODIFIES SQL DATA".
What should we do? We need MY_UDF because it is called by other SP for the scalar result. (FYI - We also call this from our J2EE application.)
What is a possible solution to this?
JJ
CREATE FUNCTION MY_UDF(date1 DATE, date2 DATE)
RETURNS DOUBLE
LANGUAGE SQL
EXTERNAL ACTION
BEGIN ATOMIC
DECLARE out_val DOUBLE;
CALL MY_SP(date1, date2, out_val);
RETURN out_val;
END
CREATE PROCEDURE MY_SP(date1 DATE, date2 DATE, out_val DOUBLE)
LANGUAGE SQL
EXTERNAL ACTION
-- logic omitted...
-- Briefly it loops through a set of values over the date range
-- in particular tables. This is done via User Defined Table.
-- Intermediate result are organized and stored in a GLOBAL TEMPORARY
-- TABLE. This information is then further processed using UPDATES.
-- The final result is single double "out_val". Like an average.
MY_SP is working fine.
But when I try to build MY_UDF, I get a SQL0374N which suggest I add in the MODIFIES SQL DATA clause. But when I do that, I get the SQL0628N Multiple or conflicting keywords involving the "MODIFIES SQL DATA".
What should we do? We need MY_UDF because it is called by other SP for the scalar result. (FYI - We also call this from our J2EE application.)
What is a possible solution to this?
JJ