Home » Infrastructure » Unix » unix script for sql result (10g, Linux RHEL4)
unix script for sql result [message #348563] Wed, 17 September 2008 04:51 Go to next message
alanm
Messages: 284
Registered: March 2005
Senior Member

all,
I have looked in the following link and there is some useful stuff

http://www.orafaq.com/wiki/Scripts#Unix_Shell_Scripts

but my requirement I do not think is covered.

I have a sql script that returns either 0 or '> 0'

can someone show me how to pass the result into a script parameter that will email me when the result is '> 0'

regards

Alan
Re: unix script for sql result [message #348567 is a reply to message #348563] Wed, 17 September 2008 05:16 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Search in the Unix forum there are many scripts to return what you want.

Regards
Michel

[Updated on: Wed, 17 September 2008 05:16]

Report message to a moderator

Re: unix script for sql result [message #348593 is a reply to message #348567] Wed, 17 September 2008 06:34 Go to previous messageGo to next message
alanm
Messages: 284
Registered: March 2005
Senior Member

I have searched in the forum and there are many pages to look through, too many unless there is a more selective search that can be done, but I cannot see one.

Also when you move a thread to a different forum it would be nice to inform the OP.

As the unix forum is used less than the server admin forum then that is why I placed the topic there.

regards

Alan
Re: unix script for sql result [message #348596 is a reply to message #348593] Wed, 17 September 2008 06:39 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
If we post here a solution, there will be one more post about this question and so it will be more difficult to find the answer.

So, I will not post (actually copy) a solution (for what? after all you didn't explain in details what you want to do).

Regards
Michel
Re: unix script for sql result [message #348651 is a reply to message #348596] Wed, 17 September 2008 08:44 Go to previous messageGo to next message
alanm
Messages: 284
Registered: March 2005
Senior Member

ok here is the script

select count(*) from dba_users where account_status !='OPEN'
and username not in (
'PROD_HCUST_HK',
'MDSYS',
'SCOTT',
'WMSYS',
'CTXSYS',
'ANONYMOUS',
'OUTLN',
'MGMT_VIEW',
'SI_INFORMTN_SCHEMA',
'ORDSYS',
'EXFSYS',
'DMSYS',
'ORACLE_OCM',
'TSMSYS',
'MDDATA',
'DIP',
'SYSMAN',
'XDB',
'ORDPLUGINS',
'OLAPSYS'
)
;


normally the result of count(*) will be '0'
if the result is 'not 0' then what I would like is a unix script which will be able to send an email to me.

regards

Alan
Re: unix script for sql result [message #348658 is a reply to message #348651] Wed, 17 September 2008 08:56 Go to previous message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You can put the result of your query inside a SQL*Plus variable and then use it to set the exit status that you can check in your shell script.

You can also directly mail from database.

Regards
Michel
Previous Topic: Subject is not able to send thr mail command in HP unix
Next Topic: failed upgrade 9.2.0.1 to 9.2.0.6 on solaris 5.10
Goto Forum:
  


Current Time: Mon Dec 02 17:00:54 CST 2024