The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to compile a stored procedure that is there with in a script file(.sql) in unix krishna_gnv Shell Programming and Scripting 0 03-11-2008 12:25 AM
Executing Stored Proc from unix prompt. arvindcgi UNIX for Advanced & Expert Users 0 01-29-2008 11:46 PM
Executing MS-SQL stored procedures from Unix/C Program? mparks SUN Solaris 3 06-22-2007 11:29 AM
Where is my unix id stored in the system? XZOR UNIX for Dummies Questions & Answers 4 07-31-2006 05:31 PM
Calling Oracle Stored Procedures in UNIx(sun solaris) etravels SUN Solaris 0 03-23-2004 03:21 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-29-2007
Registered User
 

Join Date: Aug 2006
Posts: 17
Unix Stored Procdure

I have 2 stored procedures to be executed.
if the sysdate is between 12 am and 6 am i want to run procedure 1 else procedure 2

How do i do it with variables for time in the script.
The DB is oracle

Thanks
Forum Sponsor
  #2  
Old 01-29-2007
_Spare_Ribs_'s Avatar
Registered User
 

Join Date: Dec 2006
Location: /dev/null
Posts: 72
Possibly add a script like this into your crontab. How often you want to run it in your crontab is entirely up to you and what you need this script to do...

Code:
#!/bin/bash
declare date=`date '+%H'`

if [ $date -le "6" ]
then {
	echo "Time is before 6am"
             your_procedure_1_here
	exit 0;
}
else {
	echo "Time is after 6am"
             your_procedure_2_here
	exit 0;
}
fi
exit 1;
without more specifics as to what you're trying to do and so on I couldn't really think of anything else to post but hopefully this will be of some use to you.
  #3  
Old 01-29-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Quote:
Originally Posted by _Spare_Ribs_
Possibly add a script like this into your crontab. How often you want to run it in your crontab is entirely up to you and what you need this script to do...

Code:
#!/bin/bash
declare date=`date '+%H'`

if [ $date -le "6" ]
then {
	echo "Time is before 6am"
             your_procedure_1_here
	exit 0;
}
else {
	echo "Time is after 6am"
             your_procedure_2_here
	exit 0;
}
fi
exit 1;
without more specifics as to what you're trying to do and so on I couldn't really think of anything else to post but hopefully this will be of some use to you.
Do not use a variable name which is the same as the command.

DATE=`date '+%H'`

if [ $DATE -le "6" ]
  #4  
Old 02-03-2007
Registered User
 

Join Date: Jan 2007
Posts: 22
Quote:
Originally Posted by sb008
Do not use a variable name which is the same as the command.

DATE=`date '+%H'`

if [ $DATE -le "6" ]

That doesn't matter...
  #5  
Old 02-04-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Quote:
Originally Posted by Create
That doesn't matter...
From a syntax/symantic point of view it doesn't matter.

However it improves the readability of your script enormously.
  #6  
Old 02-04-2007
Registered User
 

Join Date: Jan 2007
Posts: 22
Quote:
Originally Posted by sb008
From a syntax/symantic point of view it doesn't matter.

However it improves the readability of your script enormously.

yes, but reading a script you will be able to know the difference from a command and a variable.

*shrug* if its a large script I can see why, but sometimes, when you are doing something simple, you are just doing something simple.
  #7  
Old 02-04-2007
Registered User
 

Join Date: Jan 2007
Posts: 366
Quote:
Originally Posted by Create
yes, but reading a script you will be able to know the difference from a command and a variable.

*shrug* if its a large script I can see why, but sometimes, when you are doing something simple, you are just doing something simple.
Guess you never worked in an environment with programming standards.

Being clumsy just cause it is simple is never an argument there.

Better get used to a habit of programming in a decent way, never cost you anything.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0