Site search

Categories

Archives

Tags

awr report delete syntax demobld demobld.sql determine oracle db size du find large file ftp script function syntax insert syntax kill oracle process linux du listener listener.log nfs mount instructions oracle constraint oracle database oracle database hosting oracle delete oracle demo build oracle demo setup oracle forein key constraint oracle ftp oracle functions oracle insert oracle process Oracle Scripts oracle select oracle subquery oracle update select syntax solaris sql background sql delete sql functions sql info sql insert sqlplus demo setup sql select sql update subquery syntax Technology Webcasts update syntax vnc tutorial vsftp
RSS
XML RSS
What is this?
AddThis Feed Button

Social
Bookmarking




-- FREE --
IT Magazine
Subscriptions

Oracle Magazine Oracle Magazine Contains technology strategy articles, sample code, tips, Oracle and partner news, how-to articles for developers and DBAs

WebSite Magazine WebSite Magazine Practical advice, helpful tools and insights for website owners

Dr Dobb's Journal Dr Dobb's Journal enables coders to write the most efficient programs and help in daily programming quandaries

DM Review DM Review is recognized as the premier business intelligence, analytics and data warehousing publication
Various other Free IT magazine subscriptions
NoAdware Free Trial

NoAdware Remove
harmful
adware,
spyware,
trojans,
dialers
and worms!
- Featured ebook -

Database Normalization
by Alf Pedersen

Database Normalization ebook Understand and master how to normalize a database using methods richly documented with graphical ERD and server diagram examples



Sqlplus Bindvariables

Below is an example script (check_stby.sql) which I’ve used to compare the most
recently applied archive log file at a standby database to the most recently archived log
at the primary database.
(I know, DataGuard can do this for me with much less effort..)

I am using sql*plus bind variables because I needed to connect to 2 different databases
and compare their results.
The standby database is in mounted mode, so this precludes the idea of trying to get this information
across a database link.

The sql script is then called by a shell script. (check_stby.sh) which gets called by
a host-user-defined-metric in Enterprise Manager’s Grid Control system.

If the returned value exceeds the metric’s threshold, an alert is triggered and I receive an
email warning me to check the status of the standby database.

check_stby.sql

set echo off
set feedback off
set termout off
VARIABLE prim_seq NUMBER
variable stby_seq number
variable diff number

connect sys/xxxx@primarydb.world.com as sysdba
begin
select max(sequence#)into :prim_seq from v$archived_log;
end;
/

connect sys/xxxx@standbydb.world.com as sysdba
begin
select max(sequence#) into :stby_seq from v$log_history;
end;
/

begin
:diff := :prim_seq - :stby_seq   ;
end;
/
exit :diff;

check_stby.sh

#!/bin/ksh

export ORACLE_HOME=/home/oracle/product/10.2.0

$ORACLE_HOME/bin/sqlplus -s /nolog @check_stby.sql

echo "em_result="$?"\n"

Recommended reading: