I have created a DB2 UDF in Database1, which is referring to a table (tablename2) in Database2 through Federation setup. The function is getting complied properly in Database1. But when the UDF is getting run by running the following select query, error message is obtained
select Database1schema.UDFName() from sysibm.sysdummy1;
Error Message -
An error occurred during implicit system action type "5". Information returned for the error includes SQLCODE "-204", SQLSTATE "42704" and message tokens "schemaname.tablename2".. SQLCODE=-727, SQLSTATE=56098, DRIVER=3.64.114
-- UDF Code
CREATE or replace function Database1schema.UDFName()
returns varchar(1000)
LANGUAGE SQL
P1: BEGIN
DECLARE v_outmessage varchar(1000) default '0';
BEGIN
select a.status into v_outmessage
from database2.database2schema.tablename2 a,database1schema.tablename1 b
where a.appno = b.app_no;
END;
return v_outmessage;
END P1
PS:- Output is obtained when the select query is executed for fetching the tablename2 data from Database1, through Federation. But through function, it is not working properly. I will appreciate any help on this.