06-29-2005
Reading in two inputs from a file
Hi all,
I've been assigned the task of modifying a script which reads in names of tables from a list file, exports a 30 days worth of data from these tables, then deletes the table. The list file will now contain a table name and a number next to it indicating how many days to archive. I need to make the script read in the table name, then the number of days to go back, if no number is specified, the default will be 30. Any idea how to start off? Here is some of the current script now:
echo "Start of archive_history.ksh"
TBL_HIST_LIST=$JOB_HOME/archiveHistTbl.list
TBLLIST=$JOB_HOME/archiveTbl.list
DATADIR=/tmp
TODAY=`date +%Y%m%d`
# Set path
PATH="${JOB_HOME}:$HOME/Dear/jobs:${PATH}"
# Set date to delete from
DELDATE=`shift_date.ksh $TODAY -$1`
# For each table, delete based on dt_last_upd_hist
for tbl in `cat $TBL_HIST_LIST`
do
$ORACLE_HOME/bin/exp $DBO_USER/$DB_PASSWORD FILE=$DATADIR/$tbl-${DELDATE}.exp TABLE
S=$tbl QUERY=\"where dt_last_upd_hist \< to_date\(\'$DELDATE\', \'DD-MON-YYYY\'\
)\"
$ORACLE_HOME/bin/sqlplus $DBO_USER/$DB_PASSWORD <<!
delete from $tbl where dt_last_upd_hist < to_date('$DELDATE', 'DD-MON-YYYY');
/
!
end
done
# For each table, delete based on dt_last_upd
for tbl in `cat $TBLLIST`
do
$ORACLE_HOME/bin/exp $DBO_USER/$DBO_PASS FILE=$DATADIR/$tbl-${DELDATE}.exp TABLE
S=$tbl QUERY=\"where dt_last_upd \< to_date\(\'$DELDATE\', \'DD-MON-YYYY\'\)\"
$ORACLE_HOME/bin/sqlplus $DBO_USER/$DBO_PASS <<!
delete from $tbl where dt_last_upd < to_date('$DELDATE', 'DD-MON-YYYY');
Thanks in advance for any help!
Chris
Mods feel free to move this post if its in the wrong forum/topic.
Last edited by MadHatter; 06-29-2005 at 10:41 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a shell script that has to taken inputs from a file say "Inputs". Now I take 2 inputs at a time. Suppose the Inputs file contains numbers like
2
3
4
5
Now I have a written a script for adding 2 numbers. When I run the script for first time 2 and 3 must be the inputs. When i run the... (4 Replies)
Discussion started by: sendhil
4 Replies
2. Shell Programming and Scripting
i have an external device sending serial messages i want to connect this device to a serial port in my sun blade box and record those messages to a file, how can i read the serial port and write it to file?
Thanks (4 Replies)
Discussion started by: guilartec
4 Replies
3. Shell Programming and Scripting
Hi,
I have a file called inputs. Now that file has the values like this:
1 2 3
Now In my script called 'get.sh' I do this :
exec < inputs
read a b c d
Now I know that there will not be any value in d. How can I check it. I need the exact condition for checking whether the variable has... (1 Reply)
Discussion started by: sendhilmani123
1 Replies
4. Shell Programming and Scripting
Hi,
I have a script that takes the contents of another file as inputs. Its assumed that there are 3 values in the input file that are seperated by '|'. I have to check in my script, whether the filed seperator used in the input file is '|' or not. If its not a '|' I have to print a error... (13 Replies)
Discussion started by: sendhilmani123
13 Replies
5. UNIX for Dummies Questions & Answers
I have couple of shell scripts.
Each shell script accepts command line argument as inputfilename.
Each shell script creates a summary file, status file.
All these files are stored in a particular directory...Eg
InputFile is to be picked from /home/ProjectName/ftp_inputfiles/
Outputs are to... (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies
6. Shell Programming and Scripting
Hello;
Please I need to read inputs from a file change 1 or 2 things the output to another file. (1 Reply)
Discussion started by: jimoney
1 Replies
7. Shell Programming and Scripting
Hi All,
I am not able to read my HTML form inputs properly in my script.
I have a textarea in my form where user needs to enter sql query... but when user enter query like below :
select * from order_queue where NUM_OF_PICKUP >=3 and TRANSACTION_TYPE=4 ;
its coming like :
select 171_arc... (3 Replies)
Discussion started by: askumarece
3 Replies
8. Shell Programming and Scripting
I need to write what I thought would be a fairly simple 2-line UNIX script. It can be written PERL, csh, ksh...or whatever is easiest.
The entire script will be:
Begin Scipt
source MySourceFile
execute MyExecutable.exe
End Script
The problem is that MySourceFile can not be... (1 Reply)
Discussion started by: MMorrison
1 Replies
9. Shell Programming and Scripting
I want a script that will prompt a user to enter 10 numbers and out put them into a file. This what I have so far, but isn't working. I'm guessing it's something easy I'm not seeing. Thanks for any help.
#!/usr/bin/ksh
echo "Enter 10 numbers"
for i in 1 2 3 4 5 6 7 8 9 10
do
read .... ... (8 Replies)
Discussion started by: AxlVanDamme
8 Replies
10. Shell Programming and Scripting
Hi,
Am trying to store the user inputs into a file, but the below code will store only the first line of the values. I need to store all the user input values which may contain one or more lines. Thanks in advance.
echo "please enter file names";
read name;
echo $name>/tmp/test (11 Replies)
Discussion started by: rogerben
11 Replies
LEARN ABOUT DEBIAN
drop_table
DROP
TABLE(7) SQL Commands DROP TABLE(7)
NAME
DROP TABLE - remove a table
SYNOPSIS
DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
DESCRIPTION
DROP TABLE removes tables from the database. Only its owner can drop a table. To empty a table of rows without destroying the table, use
DELETE [delete(7)] or TRUNCATE [truncate(7)].
DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. However, to drop a table that is
referenced by a view or a foreign-key constraint of another table, CASCADE must be specified. (CASCADE will remove a dependent view
entirely, but in the foreign-key case it will only remove the foreign-key constraint, not the other table entirely.)
PARAMETERS
IF EXISTS
Do not throw an error if the table does not exist. A notice is issued in this case.
name The name (optionally schema-qualified) of the table to drop.
CASCADE
Automatically drop objects that depend on the table (such as views).
RESTRICT
Refuse to drop the table if any objects depend on it. This is the default.
EXAMPLES
To destroy two tables, films and distributors:
DROP TABLE films, distributors;
COMPATIBILITY
This command conforms to the SQL standard, except that the standard only allows one table to be dropped per command, and apart from the IF
EXISTS option, which is a PostgreSQL extension.
SEE ALSO
ALTER TABLE [alter_table(7)], CREATE TABLE [create_table(7)]
SQL - Language Statements 2010-05-14 DROP TABLE(7)