Oracle SQL*Plus – How to Quote an Identifier in a Bash Script

bashoraclescriptingsqlplus

I get "ORA-00904: "MEMORY_TARGET": invalid identifier" no matter how I try to quote the identifier in the following command:

MEMORY_TARGET=$(su - orat01 -c " echo 'select VALUE from V\$PARAMETER where name = 'memory_target';'| sqlplus / as sysdba ")

Any ideas on how to do this would be greatly appreciated.

Best Answer

[root@o73 ~]# SGA_TARGET=$(su - oracle -c "export ORACLE_SID=RYMIN19; export ORAENV_ASK=NO; . oraenv >/dev/null; echo \"set pages 0
select value from v\\\$parameter where name = 'sga_target';\" | sqlplus -s / as sysdba")
[root@o73 ~]# echo $SGA_TARGET
2147483648
[root@o73 ~]#