Apologies if this is the incorrect forum.There is an issue in the function call I am facing while calling the same from a unix shell scripts.
Basically, I want the ref cursor to return values to a variable in sqlpus. The function call is currently saved in a ".txt" file
in a unix location. I want to read the function name from the file and then execute it.But when I am running the below I get error.
Can someone please advise how to achieve the desired results?

#!/bin/ksh
sqlplus -s user/pass@server << ! < t_fn.txt
set head off
set echo off
set define off
set feedback off
set serveroutput on
var l_refcursor refcursor
exec :l_refcursor := @t_fn.txt
print l_refcursor
!

It seems my celebration was a bit early. There is one more scenario that came stating the file t_fn.txt can have more commands a part from the just the function call. For eg, it can have multiple DMLs and then the call to the function and cat t_fn.txt might show:

insert into test_a values(5555,4646,353454);
commit;
test_fn

In this scenario, the above script fails because it encounters insert instead of a cursor. Any advise on this?

@Michel - Thanks. But still it didn't work. It seems because of the DMLs before the function call, the "exec :l_refcursor := " part in the script.sql doesn't work as it searches for the return value as refcursor and it doesn't get that. It seems I have to separate the files - one file contains the DMLS and do something like:

create a file t_fn.txt with text data as the DMLs.
and then in unix :

sqlplus -s user/password@database << !
set head off
set echo off
set define off
set feedback off
set serveroutput on
set timing off
set pages 0
@t_fn.txt
var l_refcursor refcursor
exec :l_refcursor := test_fn
print l_refcursor
!

This requires a lot of manual effort because I have to segregate the huge lot of file

#!/bin/ksh
echo 'set head off
set echo off
set define off
set feedback off
set serveroutput on
var l_refcursor refcursor
@t_fn.txt
print l_refcursor
exit' >script.sql
sqlplus -s user/pass@server @script