V$ tables not recognized in a sql statement of a shell script

oraclescripting

I have .sh script with this block:

sqlplus -S / as sysdba <<EOFILE

set feedback off
set lines 2000
set pages 20000
col db_size for a15
alter session set nls_date_format = 'DD-MM-YYYY HH24:MI:SS';

select * from ( select "START_TIME", "END_TIME", INPUT_BYTES_DISPLAY db_size from v$RMAN_BACKUP_JOB_DETAILS order by "END_TIME" DESC) where ROWNUM <= 5;

EOFILE

EOF

But output is this error:

select * from ( select "START_TIME", "END_TIME", INPUT_BYTES_DISPLAY
db_size from v order by "END_TIME" DESC) where ROWNUM <= 5
* ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here

I know there is problem with accessing to v$RMAN_BACKUP_JOB_DETAILS but how should i solve this?

I tried:

v\$RMAN_BACKUP_JOB_DETAILS
'v$RMAN_BACKUP_JOB_DETAILS'
"v$RMAN_BACKUP_JOB_DETAILS"

Can someone help me? Thanks

Best Answer

Try: sqlplus -S / as sysdba <<'EOFILE' ...

Putting quotes tells the shell to not interpret the contents of the here document: it does not try to interpret $XXX in the here document as a shell variable.