Unix Stored Procdure


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Unix Stored Procdure
# 1  
Old 01-29-2007
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
# 2  
Old 01-29-2007
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
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-04-2007
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
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
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
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Calling Sybase Stored proc from UNIX Shellscript.

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File, somehow i tried to find a solution but when i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies

2. Shell Programming and Scripting

How to KIll a Stored procedure invoked by UNIX?

Hi, I am using sql server 2008 version and invoking the stored procedure using unix script. I want to know the procedure of killing the stored procedure in sql server. If I kill -9 the unix script will it also terminate the process at the SQL server. When I executed the kill -9 PID in unix... (2 Replies)
Discussion started by: Rahul Raj
2 Replies

3. Shell Programming and Scripting

Unix path stored as a column in table

The db2 table stores the unix path as below PARM VALUE RootPath $SRootDir Target $SRootDir/target $SRootDir is set in the env variable as /home/test/root In the shell script i read the table value and store it in a variable pth=db2 -x "select VALUE from... (2 Replies)
Discussion started by: 2jnags
2 Replies

4. Shell Programming and Scripting

Passing a value to stored procedure from unix shell script

Hi Dudes :) I want a unix shell script to pass value to SQL stored procedure. Below is the procedure declare res varchar2(10); begin odm_load_check('PRE_SANITY',res); dbms_output.put_line(res); end; select * from error_log; truncate table error_log; select * from test; (1 Reply)
Discussion started by: shirdi
1 Replies

5. UNIX for Dummies Questions & Answers

Calling stored procedure from unix

Hi, My stored procedure returns a value. How to retrieve the value and display in unix. Stored procedure CREATE OR REPLACE PROCEDURE gohan(num INT) IS BEGIN DBMS_OUTPUT.PUT_LINE('My lucky number is ' || num); END; Unix Scripting i used sqlplus -s... (7 Replies)
Discussion started by: gohan3376
7 Replies

6. Shell Programming and Scripting

Oracle Query results to be stored in variables using unix

I want to store the sql query output into a variable #!/bin/ksh ORACLE_SID=DB01; export ORACLE_SID; export FILE_PATH=/home/asg/Tmp # Order Checking echo " removing old files " rm $FILE_PATH/Malformed_Order.txt echo " Enter the Malformed Order ....!" read orders echo "Regrade... (5 Replies)
Discussion started by: Nareshp
5 Replies

7. Shell Programming and Scripting

Need to call stored procedure from unix script

Hi Guys, I have a stored procedure which has 5 out parameters. I need to call the stored procedure from the script. When i use the following in my script, db2 "CALL FCFM.PART_MASTER_TMP($Return_code,$Message,$Message1,$SQL,$Load_count)" >> $LOG_FILE I am getting an error.. Please... (1 Reply)
Discussion started by: mac4rfree
1 Replies

8. UNIX for Advanced & Expert Users

Executing Stored Proc from unix prompt.

Hi All, I want to run/execute a stored procedure (sybase) from unix command prompt not by login in isql utility which is provided my Sybase guys. Is there way ..? Thanks in advance for your help !!! Regards, Arvind S. (0 Replies)
Discussion started by: arvindcgi
0 Replies

9. Solaris

Executing MS-SQL stored procedures from Unix/C Program?

All, We are contemplating a port of an existing software product and would like to expend as little effort as possible. Our new database would be MS-SQL, and we would write stored procedures to perform common db operations. We'd like to call these stored procedures from C or C++ code running... (3 Replies)
Discussion started by: mparks
3 Replies

10. UNIX for Dummies Questions & Answers

Where is my unix id stored in the system?

Hi, I logged in to a Sun unix box. I would like to know where my unix id is stored. So I did a "more /etc/passwd | grep <my unix id> but it did not show up. Where can I find my unix id and what is the command to see it? Thanks in advanced, XZOR (4 Replies)
Discussion started by: XZOR
4 Replies
Login or Register to Ask a Question