Quote:
|
Above code will return a table
|
No.
If the select statement in your code returns only one row,
the return statement in my example will return a scalar value.
If the select statement in your code returns multiple rows,
you should decide a row which should be returned.
One way may be to add FETCH FIRST 1 ROW ONLY (and optional ORDER BY clause), like...
Code:
CREATE OR REPLACE FUNCTION
...
...
RETURN
SELECT CAST(DSS_RNG_CD AS SMALLINT)
FROM INTDM.TBINTL_RNG_CD_XREF
WHERE GETDSSRANGE.AMOUNT BETWEEN DSS_LWLM_NO AND DSS_UPLM_NO
AND DSS_RNG_TY_NM ='ASSET'
ORDER BY ...
FETCH FIRST 1 ROW ONLY
;