I sent this out to the DB2-L server yesterday, but didn't get much in the way of responses, maybe someone on here can help shed some light on my woes. We wrote a UDF in COBOL(udf external scalar) that given some inputs will go out and find the person id that those values were entered for. The underlying purpose of this UDF was to enable us to use the UDF in a before insert trigger for denormalizing some tables to eliminate a ton of I/O. When I try to use the UDF in an insert, I get a -450 which states I'm overlaying storage. The data types and lengths of the values have been verified several times in both the table definitions, the UDF definition and in the COBOL working storage and linkage.
The UDF definition is:
CREATE FUNCTION SQLTOOLS.GET_PERSON
(col1 INTEGER,
col2 CHAR ( 1 ) FOR SBCS DATA CCSID EBCDIC,
col3 INTEGER,
col4 SMALLINT)
RETURNS SYSIBM.INTEGER
SPECIFIC SQLTOOLS.GET_PERSON
EXTERNAL NAME 'UDFGTPRS'
LANGUAGE COBOL
PARAMETER STYLE DB2SQL
DETERMINISTIC
FENCED
RETURNS NULL ON NULL INPUT
NO SQL
NO EXTERNAL ACTION
SCRATCHPAD 16
FINAL CALL
DISALLOW PARALLEL
DBINFO
COLLID DB2U85
WLM ENVIRONMENT DBT1WLMU
STAY RESIDENT YES
PROGRAM TYPE MAIN
SECURITY DB2
INHERIT SPECIAL REGISTERS
The trigger definition is:
CREATE TRIGGER mytrig NO CASCADE BEFORE INSERT
ON my_ins_table REFERENCING NEW AS NROW
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
SET NROW.I_PERSON = SQLTOOLS.GET_PERSON( NROW.col1 ,
NROW.col2 ,NROW.col3 ,NROW.col4);
END ~
--#SET TERMINATOR ;
When I try to select a row(s) from a table using the UDF, I get a -440 function does not exist. The query is of the type:
SELECT * FROM mytable
WHERE I_PERSON = SQLTOOLS.GET_PERSON(2007064,'7',6828,1)