How to return the result of a select query in a function

Database
Enthusiast

How to return the result of a select query in a function

Hello to everybody,

I'm trying to return the result of a select query in a function. Something like:

REPLACE FUNCTION F_SIGUIPUNTERO_F (nPunt number, nLimite number) RETURNS int

LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
SQL SECURITY DEFINER
COLLATION INVOKER
INLINE TYPE 1

RETURN
NVL(CALL DBC.SYSEXECSQL('select top 1 ID from TMP_CADENA where VALOR is not null and ID > ' || nPunt || ' order by ID;'), nLimite+1);
END
;

But it's not working. Also, I think that the DBC.SYSEXECSQL is not being detected properly...

Could anyone help me?

Thanks and regards

Juan
Tags (1)