原码如下
su - oracle -c "sqlplus -s test/test_2024 > /tmp/rman_size.log<<EOF
SET pagesize 0
select to_char(RMAN_SIZE) from (select to_char(start_time,'yyyy-mm-dd') start_time,to_char(start_time,'day') day,device_type,sum(OUTPUT_BYTES) RMAN_SIZE
from v$backup_set_details where INCREMENTAL_LEVEL=0 group by to_char(start_time, 'yyyy-mm-dd'),INCREMENTAL_LEVEL,BACKUP_TYPE,device_type,
to_char(start_time,'day') order by start_time desc ) c where rownum=1;
EOF"
执行报错
[root@centos610 work]# ./a.sh
[root@centos610 work]# cat /tmp/rman_size.log
from v where INCREMENTAL_LEVEL=0 group by to_char(start_time, 'yyyy-mm-dd'),INCREMENTAL_LEVEL,BACKUP_TYPE,device_type,
*
ERROR at line 2:
ORA-04044: procedure, function, package, or type is not allowed here
转义一次sql脚本中的$符号
su - or