I am new to Oracle and have been tasked with executing a number of stored procedures that will return either a time stamp or a number, and then alert on them based on the thresholds.
I know how to execute MSSQL and MySQL SPs but it seems that Oracle isn't the same.
For database queries I use the CPAN DBI perl module which works fine.
I can run a basic query against an Oracle DB ok but not execute an SP.
The connection part of my code is:
#############################################
$dbh = DBI->connect("dbi:Oracle:host=$server;port=$port;sid=$db",$dbusername,$dbpassword, {RaiseError => 0, AutoCommit => 0}) || die;
$select = "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR";
$sth = $dbh->prepare($select) || die "\$sth not created!\n";
$sth->execute();
@res = $sth->fetchrow_array();
$sth->finish();
$dbh->disconnect();
$res = $res[0];
print "$res\n";
##################################
And the error I get is:
##################################
DBD::Oracle::st execute failed: ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute) [for Statement "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR"]
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement "EXEC DKURTULAY.NAGIOS_SMS_TABLE_CHECK.SMS_COUNT_PASTHOUR"]
##################################
I would appreciate any help.
Thanks
Tony
Running Oracle Stored Procedures
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Running Oracle Stored Procedures
Have you look through the Oracle plugins? https://exchange.nagios.org/directory/P ... ses/Oracle. I didn't see anything that seemed to do exactly what you want.
You may end up having to use event handlers: https://assets.nagios.com/downloads/nag ... dlers.html
Please let us know if you think either of those solutions will work for you.
You may end up having to use event handlers: https://assets.nagios.com/downloads/nag ... dlers.html
Please let us know if you think either of those solutions will work for you.