I'm trying to automate the following script to be added to crontab which will automate the deployment of five sql scripts based on day of week. I've got three questions pertaining to the following:
1. Our server date+time is running on GMT; how do I get perl to reflect day of week for GMT-4?
2. I'm not sure if my sqlplus parameters are correct. The hardcoded values passed DO need to have a single quotation mark included when being passed. Is the way I've coded it, correct?
3. Lastly, I'm calling sqlplus each time and passing user/passwd/sid for each script being called. Since each script should be running sequentially after each other, should I remove sqlplus for all subsequent calls? What is the best way to code this?
Use TZ variable to set the time zone. You did not specify your OS, so a solaris example
Lose the perl, use
BE CAREFUL when you use relative paths (./) in cron.
crontab example
Then shorten your code sorta like this:
This User Gave Thanks to jim mcnamara For This Post:
Sometimes, you can impose a different time zone on the session, else subtract 4 hours from time using oracle time arithmetic.
Quoted quotes seems overkill, but if it works, great! I prefer to generate the input stream to one sqlplus command, with all the commands, "echo '... everything' | sqlplus ...." to save on connect fork exec overhead, and if there is any transactioning, you need to stay in one session. DB2 has a shadow process holding one session, so you can use this ugly, counterintuitive pragma, but as I recall every sqlplus is a new session. If you echo double quoted big string, you can use single on strings, just watch out for shell meta. I prefer to echo in single quotes, where little happens, and use '"'"' for each literal single quote. I am not sure if it is cheaper than <<, but << is very open to meta-shell expansion. Throw in lots of line feeds for beautification, and indentation if necessary. Do 'select scriptname from dual' or something before each script.
Use a wrapper script name in cron. Immediately wrap everything in "() >>log_file 2>&1" so everything is logged outside cron, and use date to put out time stamped run header+trailer messages.
Last edited by DGPickett; 06-10-2011 at 11:59 AM..
---------- Post updated at 11:21 AM ---------- Previous update was at 11:09 AM ----------
Gurus,
I sincerly apologize. I think I did not explain myself properly. Your recommendations are top notch.
I will be creating four of these scripts: dates for Q1, Q2, Q3, and Q4. Each script will be called once per day to convert data for the specified year based on which day of week it is. Monday we'll be converting for year 2005, Tuesday for 2006, etc. The year will not be passed in from cron. Actually no parameters will be passed from cron.
You have answered most of my question based on your responses anyway. I'm still a little confused as to how to code DOW to consider EDT offset.
Jim said to lose the Perl, ok. Then how does that get applied with the offset.
---------- Post updated at 11:21 AM ---------- Previous update was at 11:09 AM ----------
Gurus,
I sincerly apologize. I think I did not explain myself properly. Your recommendations are top notch.
I will be creating four of these scripts: dates for Q1, Q2, Q3, and Q4. Each script will be called once per day to convert data for the specified year based on which day of week it is. Monday we'll be converting for year 2005, Tuesday for 2006, etc. The year will not be passed in from cron. Actually no parameters will be passed from cron.
You have answered most of my question based on your responses anyway. I'm still a little confused as to how to code DOW to consider EDT offset.
Jim said to lose the Perl, ok. Then how does that get applied with the offset.
Thanks in advance for your help.
Why do you need 4 scripts? Create just one script and have it figure out what day of the it's running on and make determination based on that what year to run the 'conversion' for - should be pretty easy/basic to implement.
Thanks for replying. The whole story is that we'll be executing each of the four scripts at different points during the day. We'll include each quarterly script as an entry in the cron.
The reason we're doing this is because our replication environment is spewing a boatload of alerts due to the volume of updates, not to mention, the load backing up.
Any additional help with the GMT-4 issue would be great.
Big operations especially transactions are a drag on any system. They lack locality of reference, run at disk speed not RAM and CACHE speeds. Do an hour, day, week at a time and wait between batches as long as the batch took for the interactive users, and let it chug. You could even collect all the rowids first, and then do 1024 rowids at a time. Think about it: you get 99+% of economy of scale doing 101 rows! Everything past that may be tiny or even a slowdown. If you make it a stored procedure or anonymous block, and let it run inside the engine, compile/plan time is eliminated. Then, there is locking . . . !
Last edited by DGPickett; 06-10-2011 at 03:44 PM..
i am using bash shell
Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127.
IFS=","
declare -a Arr=($Variable1);
SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE}
echo "set head off ; " > ${SQLCMD}
echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Hello All,
I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible?
Thanks (4 Replies)
Hi All,
I am trying to dowmload the zip file "zkManageCustomers.zip " but i dont have access. Can anyone help me to download this file
See the below link-
http://www.ibm.com/developerworks/opensource/library/wa-aj-open/index.html?ca=drs-
Please help me as early as... (1 Reply)
Gurus,
The issue I'm having is that my Shell won't accept SQL parameters properly......
Here's they way I'm running it....
applmgr@ga006hds
=> sh CW_MigrationDeployScript.sh apps <appspwd> <SID> '01-JAN' '31-MAR'
The process just hangs not submitting the SQL job...
... (3 Replies)
I have a file which is tab delimited, it contains the GMT date.
Please tell me how to convert from GMT to PST time and if the date and time is of 2 days ago from the current date store the lines in a file or else remove the line.
10.1.10.178 - - -
10.1.10.178 - - ... (2 Replies)
Hello,
On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command.
tunrestore -R is present in inittab
in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log
... (0 Replies)
Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files..
Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this?
Please tell me... (2 Replies)
Hi,
I am trying to pass some of the variables in my shell scripts to the sqlplus call and use them as parameters.
For example, I would like to replace the 'SAS', and '20050612' with $var1 and $var2, respectively, how can I do that?
--------------------------------------------------------... (1 Reply)
Hi ,
I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script
Right now no file is generated on the unix box...it is a... (2 Replies)