LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Getting error while getting status of active and inactive sessions from ORACLE DB (https://www.linuxquestions.org/questions/linux-newbie-8/getting-error-while-getting-status-of-active-and-inactive-sessions-from-oracle-db-834656/)

saurabhmehan 09-26-2010 09:54 PM

Getting error while getting status of active and inactive sessions from ORACLE DB
 
Hi All,

I have a written a test script which retrieves the status of active and inactive sessions from oracle DB, but i am receiving error while executing.

My script is
Code:

filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"
INACTIVE_SESSIONS=`/home/ocsg/client10g/bin/sqlplus -s abc/abc@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=test)))' << EOFSQL
set head off
select count(*) from V$SESSION;
exit;
EOFSQL`
echo $INACTIVE_SESSIONS > $filepath
echo DB SESSION REPORT : $INACTIVE_SESSIONS

and error i receive when executing the above script is as follows:
Code:

db_session_alert ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here
Please help me where i am wrong in the above script.

TB0ne 09-27-2010 09:58 AM

Quote:

Originally Posted by saurabhmehan (Post 4109842)
Hi All,

I have a written a test script which retrieves the status of active and inactive sessions from oracle DB, but i am receiving error while executing.

My script is
Code:

filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"
INACTIVE_SESSIONS=`/home/ocsg/client10g/bin/sqlplus -s abc/abc@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=test)))' << EOFSQL
set head off
select count(*) from V$SESSION;
exit;
EOFSQL`
echo $INACTIVE_SESSIONS > $filepath
echo DB SESSION REPORT : $INACTIVE_SESSIONS

and error i receive when executing the above script is as follows:
Code:

db_session_alert ERROR at line 1: ORA-04044: procedure, function, package, or type is not allowed here
Please help me where i am wrong in the above script.

Obviously, based on the error message, you'd have the problem on line 1, as it clearly says. So, move that line to further down in your script, or check the syntax of what you're trying to do.

healyma 09-27-2010 10:39 AM

That test script looks like it should be typed into a console (especially the EOFSQL stuff). Put the bold part below on one line in your script and see if it works

filepath="/home/ocsg/scripts/db_session_report/current_session_report.txt"
/home/ocsg/client10g/bin/sqlplus -s abc/abc@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP(HOST=10.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID =test)))' set head off select count(*) from V$SESSION; exit; > $filepath
echo DB SESSION REPORT : $INACTIVE_SESSIONS


All times are GMT -5. The time now is 12:25 PM.