I have an sqlplus script which needs to call a function. This function creates an SQL select dynamically and has already been compiled in the database. My script needs to call this function, executes the SQL request it returns and then spool the data in a CSV file. My SQLPLUS code is below:
SET HEAD OFF
SET TRIMOUT ON
SET TRIMSPOOL ON
SET LINESIZE 32000
SET PAGESIZE 0
SET TERMOUT OFF
SET ECHO OFF
SET COLSEP ,
spool /a/b/rvibap/c/&1..csv
EXECUTE IMMEDIATE build_select(&1)
spool off;
/
However, I am getting the below error in my CSV file:
BEGIN IMMEDIATE build_select(TYPE); END;
*
ERROR at line 1:
ORA-06550: line 1, column 17:
PLS-00103: Encountered the symbol "BUILD_SELECT" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "BUILD_SELECT" to continue.
I am calling my SQL script in the following way :
@test.sql TYPE
I have also tested the build_select function and it functions correctly; return a query in String.