I have created a UDF function to lookup a reference table
CREATE OR REPLACE function udf_rdm_lookup_func_test(
src_system VARCHAR,
src_code VARCHAR,
src_value varchar)
returns array
as
$$
SELECT DISTINCT DESC FROM rdm WHERE SOURCE_CODE = SRC_CODE AND SOURCE_VALUE = SRC_VALUE AND SOURCE_SYSTEM = SRC_SYSTEM
$$
;
i am able to call the UDF in a simple SELECT query
select udf_rdm_lookup_func_test('XYZ','LOBCode','001');
but i want to use this as a lookup in while reading data from another table
SELECT DISTINCT COMPANY_CODE,SRC_SYSTEM_ID,
udf_rdm_lookup_func_test(SRC_SYSTEM_ID,'LOBCode',COMPANY_CODE)[2]
FROM ABC;
Upon running that i am getting an error
SQL Error [2031] [42601]: SQL compilation error:¶Unsupported subquery type cannot be evaluated
Want to know how to create a function that can be used in a SELECT statement while reading data from another table? Please help