Bash Script to run a sql file (Draft) – Part 1

#!/usr/bin/bash

# This script calls the Ad_1.sql script and spools the output with date stamp to a log file
# Update: You MUST add your environment variables one way or another, e.g. look below

export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/OraHome_1
PATH=${PATH}:${ORACLE_HOME}/bin; export PATH
export LIBPATH=${LIBPATH}:${ORACLE_HOME}/lib32:${ORACLE_HOME}/lib

if [ ! -f lock ]; then

sqlplus -s user/password@sid << EOF
column dcol new_value mydate noprint
select sysdate dcol from dual;
spool log_ad_1_&mydate..log
@Ad_1.sql;
spool off
EOF

fi

where:

if [ ! -f lock ]: very useful statement, it checks whether a file named “lock” exists or not, if it doesn’t exist, it will not execute the code block within.

sqlplus -s usr/passwod@sid: to run sqlplus commands as if I’m entering the commands manually, the -s flag lets sqlplus accept the standardin input until it finds the word “EOF”

Part 2 will be about adding the above script in crontab and executing it daily.

Tagged , | Leave a comment

Putting the Current Date in a Spool File Name in sqlplus

 Using SYSDATE you can query the current date and put it in a substitution variable. The substitution variable can then be used in a SPOOL command:

column dcol new_value mydate noprint
select to_char(sysdate,’YYYYMMDD’) dcol from dual;
spool &mydate.report.txt


— my report goes here
select last_name from employees;
spool off

Tagged | Leave a comment

Some useful Google Chrome extensions that I use – Part 3

Well, this is the article number 200 in this blog, I’m so proud of this 🙂

  1. Copy Without Formatting: Enables you to copy text from any website without its formatting, very useful in some situations where you just need to extract the text without its specific font, color …etc, I found it very useful in blogging, there is a similar addon for firefox that does the same exactly.
Tagged , , | Leave a comment

Some useful Google Chrome extensions that I use – Part 2

  1. SmoothScroll: As the name indicates, it allows smooth scrolling of the web page, makes chrome more elegant 🙂
  2. MiddleButtonScroll: A feature that I really wanted and couldn’t find at first on Chrome is the ability to click the middle mouse button and smoothly scroll upwards or downwards by just moving the mouse, this extension does exactly this!
  3. Stop Autoplay for YouTube: As the name indicates, whenever you open a youtube video, especially when opening many videos simultaneously in multiple tabs, it stops the video from auto-playing and guess what, it pre-buffers as well :), i.e. it starts loading the video as if you clicked the pause button.
  4. Webpage Screenshot: As the name indicates, it allows you to take screenshots of the webpages you browse, it can also add large pages – that require scrolling – in one screenshot.
Tagged , , , , | Leave a comment