Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to check the status of a sql script

RE: How to check the status of a sql script

From: Brian MacLean <bmaclean_at_homebid.com>
Date: Fri, 16 Jun 2000 07:53:53 -0700
Message-Id: <10530.109551@fatcity.com>


This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible.

------_=_NextPart_001_01BFD7A2.B0B8813E
Content-Type: text/plain;

        charset="windows-1252"

Yup! (#@!$% copy paste)

-----Original Message-----
From: David Lee [mailto:dba_lee_at_hotmail.com] Sent: Thursday, June 15, 2000 12:28 PM
To: brian.maclean_at_homebid.com
Subject: RE: How to check the status of a sql script

Hi Brian,
This is nice. I am gonna use it.
I am wondering if there is a typo in your script: The line after the "Backup commands here". Shouldn't the argument to the function be 'end' instead of 'begin'? I just want to make sure.

Thanks

David

>From: Brian MacLean <bmaclean_at_homebid.com>
>Reply-To: ORACLE-L_at_fatcity.com
>To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
>Subject: RE: How to check the status of a sql script
>Date: Thu, 15 Jun 2000 11:40:53 -0800
>
>A partial Korn shell example to get you going...
>
>#!/bin/ksh
>#
># args for DB_TBLS_Status: 1=tablespace_name 2=begin/end
>function DB_TBLS_Status {
> sqlplus / <<EOF
> alter tablespace ${1} ${2} backup;
> select 'STATUS=' || B.status
> from dba_data_files A, v$backup B
> where A.tablespace_name = 'USERS'
> and A.file_id = B.file#;
> exit;
>EOF
>}
>#
>DB_TBLS_Status ${my_tablespace} begin | grep "STATUS=ACTIVE"
>if [ ${?} -eq 0 ]
>then
> echo "Begin backup successful for tablespace ${my_tablespace}"
>else
> echo "Begin backup failed for tablespace ${my_tablespace}, exiting..."
> exit
>fi
>#
># BACKUP COMMANDS HERE
>#
>DB_TBLS_Status ${my_tablespace} begin | grep "STATUS=NOT ACTIVE"
>if [ ${?} -eq 0 ]
>then
> echo "End backup successful for tablespace ${my_tablespace}"
>else
> echo "End backup failed for tablespace ${my_tablespace}, exiting..."
> exit
>fi
>#END-OF-SCRIPT
>
>
>
>
>Brian P. Mac Lean
>Senior Oracle Database Administrator
>OCPv8/Oracle Master
>HomeBid.Com
>8700 N. Gainey Center Drive
>Scottsdale, AZ 85258
>Tel:480.609.4624
>Cel:602.617.6075
>Fax:480.609.4646
>Net:brian.maclean_at_homebid.com
>
>
>
>-----Original Message-----
>Sent: Thursday, June 15, 2000 11:16 AM
>To: Multiple recipients of list ORACLE-L
>
>
>Hi all,
>I am writing a shell script to do hot backups. I have a sql script
>embedded
>
>in it saying ' alter tablespace ... begin backup' stuff.
>Now I want to put something in my shell script so that if the sql script
>fails, the hot backups are cancelled and tablespaces are taken out of
>hot backup mode. But the thing is, How do I see the exit status of the sql
>script?
>
>TIA
>
>David
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>--
>Author: David Lee
> INET: dba_lee_at_hotmail.com
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing Lists
>



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

------_=_NextPart_001_01BFD7A2.B0B8813E
Content-Type: text/html;

        charset="windows-1252"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2448.0">
<TITLE>RE: How to check the status of a sql script</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Yup! (#@!$% copy paste)</FONT>
</P>
<BR>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: David Lee [<A HREF="mailto:dba_lee_at_hotmail.com">mailto:dba_lee_at_hotmail.com</A>]</FONT>
<BR><FONT SIZE=2>Sent: Thursday, June 15, 2000 12:28 PM</FONT>
<BR><FONT SIZE=2>To: brian.maclean_at_homebid.com</FONT>
<BR><FONT SIZE=2>Subject: RE: How to check the status of a sql script</FONT>
</P>
<BR>

<P><FONT SIZE=2>Hi Brian,</FONT>
<BR><FONT SIZE=2>This is nice. I am gonna use it.</FONT>
<BR><FONT SIZE=2>I am wondering if there is a typo in your script:</FONT>
<BR><FONT SIZE=2>The line after the &quot;Backup commands here&quot;.</FONT>
<BR><FONT SIZE=2>Shouldn't the argument to the function be 'end' instead of 'begin'?</FONT>
<BR><FONT SIZE=2>I just want to make sure.</FONT> </P>

<P><FONT SIZE=2>Thanks</FONT>
</P>

<P><FONT SIZE=2>David</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>&gt;From: Brian MacLean &lt;bmaclean_at_homebid.com&gt;</FONT>
<BR><FONT SIZE=2>&gt;Reply-To: ORACLE-L_at_fatcity.com</FONT>
<BR><FONT SIZE=2>&gt;To: Multiple recipients of list ORACLE-L &lt;ORACLE-L_at_fatcity.com&gt;</FONT>
<BR><FONT SIZE=2>&gt;Subject: RE: How to check the status of a sql script</FONT>
<BR><FONT SIZE=2>&gt;Date: Thu, 15 Jun 2000 11:40:53 -0800</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;A partial Korn shell example to get you going...</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;#!/bin/ksh</FONT>
<BR><FONT SIZE=2>&gt;#</FONT>
<BR><FONT SIZE=2>&gt;# args for DB_TBLS_Status: 1=tablespace_name 2=begin/end</FONT>
<BR><FONT SIZE=2>&gt;function DB_TBLS_Status {</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; sqlplus / &lt;&lt;EOF</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; alter tablespace ${1} ${2} backup;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; select 'STATUS=' || B.status</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from dba_data_files A, v$backup B</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where A.tablespace_name = 'USERS'</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and A.file_id = B.file#;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; exit;</FONT>
<BR><FONT SIZE=2>&gt;EOF</FONT>
<BR><FONT SIZE=2>&gt;}</FONT>
<BR><FONT SIZE=2>&gt;#</FONT>
<BR><FONT SIZE=2>&gt;DB_TBLS_Status ${my_tablespace} begin | grep &quot;STATUS=ACTIVE&quot;</FONT>
<BR><FONT SIZE=2>&gt;if [ ${?} -eq 0 ]</FONT>
<BR><FONT SIZE=2>&gt;then</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; echo &quot;Begin backup successful for tablespace ${my_tablespace}&quot;</FONT>
<BR><FONT SIZE=2>&gt;else</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; echo &quot;Begin backup failed for tablespace ${my_tablespace}, exiting...&quot;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; exit</FONT>
<BR><FONT SIZE=2>&gt;fi</FONT>
<BR><FONT SIZE=2>&gt;#</FONT>
<BR><FONT SIZE=2>&gt;# BACKUP COMMANDS HERE</FONT>
<BR><FONT SIZE=2>&gt;#</FONT>
<BR><FONT SIZE=2>&gt;DB_TBLS_Status ${my_tablespace} begin | grep &quot;STATUS=NOT ACTIVE&quot;</FONT>
<BR><FONT SIZE=2>&gt;if [ ${?} -eq 0 ]</FONT>
<BR><FONT SIZE=2>&gt;then</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; echo &quot;End backup successful for tablespace ${my_tablespace}&quot;</FONT>
<BR><FONT SIZE=2>&gt;else</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; echo &quot;End backup failed for tablespace ${my_tablespace}, exiting...&quot;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; exit</FONT>
<BR><FONT SIZE=2>&gt;fi</FONT>
<BR><FONT SIZE=2>&gt;#END-OF-SCRIPT</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Brian P. Mac Lean</FONT>
<BR><FONT SIZE=2>&gt;Senior Oracle Database Administrator</FONT>
<BR><FONT SIZE=2>&gt;OCPv8/Oracle Master</FONT>
<BR><FONT SIZE=2>&gt;HomeBid.Com</FONT>
<BR><FONT SIZE=2>&gt;8700 N. Gainey Center Drive</FONT>
<BR><FONT SIZE=2>&gt;Scottsdale, AZ&nbsp; 85258</FONT>
<BR><FONT SIZE=2>&gt;Tel:480.609.4624</FONT>
<BR><FONT SIZE=2>&gt;Cel:602.617.6075</FONT>
<BR><FONT SIZE=2>&gt;Fax:480.609.4646</FONT>
<BR><FONT SIZE=2>&gt;Net:brian.maclean_at_homebid.com</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;-----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt;Sent: Thursday, June 15, 2000 11:16 AM</FONT>
<BR><FONT SIZE=2>&gt;To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Hi all,</FONT>
<BR><FONT SIZE=2>&gt;I am writing a shell script to do hot backups. I have a sql&nbsp; script </FONT>
<BR><FONT SIZE=2>&gt;embedded</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;in it saying ' alter tablespace ... begin backup' stuff.</FONT>
<BR><FONT SIZE=2>&gt;Now I want to put something in my shell script so that if the sql script</FONT>
<BR><FONT SIZE=2>&gt;fails, the hot backups are cancelled and tablespaces are taken out of</FONT>
<BR><FONT SIZE=2>&gt;hot backup mode. But the thing is, How do I see the exit status of the sql</FONT>
<BR><FONT SIZE=2>&gt;script?</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;TIA</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;David</FONT>
<BR><FONT SIZE=2>&gt;________________________________________________________________________</FONT>
<BR><FONT SIZE=2>&gt;Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;--</FONT>
<BR><FONT SIZE=2>&gt;Author: David Lee</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; INET: dba_lee_at_hotmail.com</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Fat City Network Services&nbsp;&nbsp;&nbsp; -- (858) 538-5051&nbsp; FAX: (858) 538-5051</FONT>
<BR><FONT SIZE=2>&gt;San Diego, California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Public Internet access / Mailing Lists</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
</P>
<P><FONT SIZE=2>________________________________________________________________________</FONT>
Received on Fri Jun 16 2000 - 09:53:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US