Sponsored Content
Top Forums Shell Programming and Scripting Delete the records from table Post 302846435 by zxcjggu708 on Saturday 24th of August 2013 01:49:38 AM
Old 08-24-2013
Lightbulb Delete the records from table

Thank you very much for your response.
Yes, that is what I wanted to do, and my table contains such records which have year as 2011.
Now I found the solution Smilie, actually I inserted the records with date pattern as '23-JUN-11' and in the below command

Code:
delete from MWDEVUSR.PIERBRIDGE_TENANT_XREF where to_char(CONTRACT_ENDDATE,'yyyy') <= (select (to_char(sysdate,'yyyy')- ${1}) from dual);

that is why it is not deleting the records from the tableSmilie

I changed the command to below,and now it is working fine.

Code:
delete from MWDEVUSR.PIERBRIDGE_TENANT_XREF where to_char(CONTRACT_ENDDATE,'yy') <= (select (to_char(sysdate,'yy')- ${1}) from dual);

Thanks once again.

Last edited by Scrutinizer; 08-24-2013 at 06:56 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting records from flat file to db table

I have 20000 numbers present in a file in each line like 25663, 65465, 74579, 56446, .. .. I have created a table in db with single number column in it. create table testhari (no number(9)); I want to insert all these numbers into that table. how can i do it? can anybody please... (4 Replies)
Discussion started by: Hara
4 Replies

2. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

3. Shell Programming and Scripting

How do I load records from table to a flat file!

Hi All, I need to load records from oracle table XYZ to a flat file say ABC.dat. could any one tell me how do i do this in UNXI, Regards Ann (1 Reply)
Discussion started by: Haque123
1 Replies

4. Shell Programming and Scripting

Verifying table records

Hi, Script copies records of two tables into another tables for backup before using oracle's import utility to restore from backup. Now, suppose if the import utility fails then the script will again copy those records from the backup table to the original ones. How to check whether all... (2 Replies)
Discussion started by: milink
2 Replies

5. Shell Programming and Scripting

Total records in table

Hi, I am having two tables. A & B I want to know the total number of records in each table and need to store each value in some variables to process further in the code. How it can be done ? With Regards (2 Replies)
Discussion started by: milink
2 Replies

6. Shell Programming and Scripting

Getting number of records from a table

I am doing a loading process. I am loading data from a Oracle source to Oracle target. For example there is an SQL statement: Insert into emp_1 Select * from emp_2 where deptno=20; In this case my source is emp_2 and loading into my target table emp_1. This process is automated. Now I... (3 Replies)
Discussion started by: karthikkasarla
3 Replies

7. Shell Programming and Scripting

Find highest records in table

Dear All, I have table files with different measurements for the same sensors. The first column indicate the sensor (7 different sensors and 16 measurements in the example below). I would like to find the best measurement for each sensor. The best measurement is determined by the higher value of... (10 Replies)
Discussion started by: GDC
10 Replies

8. Shell Programming and Scripting

UNIX Script required for count the records in table

Hi Friends, I looking for the script for the count of the records in table. and then it's containg the zero records then should get abort. and should notify us through mail. Can you please help me out in this area i am lacking. (5 Replies)
Discussion started by: victory
5 Replies

9. Shell Programming and Scripting

Intelligent Script to Insert Records in Database Table

Hello All Members, I am new to this forum and to the shell scripting. I want to write a shell script to do the following: Scenario: I have a pipe delimited .txt file with multiple fields in it. The very first row of the file contains the name of the column which resembles the name of the... (18 Replies)
Discussion started by: chetanojha
18 Replies

10. UNIX for Beginners Questions & Answers

1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected. LOAD DATA infile ' ' #specifies the name of a datafile containing data that you want to load BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies
PKG_DELETE(1)						    BSD General Commands Manual 					     PKG_DELETE(1)

NAME
pkg_delete -- a utility for deleting previously installed software package distributions SYNOPSIS
pkg_delete [-ADFfkNnORrVv] [-K pkg_dbdir] [-P destdir] [-p prefix] pkg-name ... DESCRIPTION
The pkg_delete command is used to delete packages that have been previously installed with the pkg_add(1) command. The given packages are sorted, so that the dependencies needed by a package are deleted after the package. Before any action is executed, pkg_delete checks for packages that are marked as preserved or have depending packages left. If the -k flag is given, preserved packages are skipped and not removed. Unless the -f flag is given, pkg_delete stops on the first error. WARNING
Since the pkg_delete command may execute scripts or programs provided by a package file, your system may be susceptible to ``Trojan horses'' or other subtle attacks from miscreants who create dangerous package files. You are advised to verify the competence and identity of those who provide installable package files. For extra protection, examine all the package control files in the package record directory <PKG_DBDIR>/<pkg-name>/). Pay particular attention to any +INSTALL or +DEINSTALL files, and inspect the +CONTENTS file for @cwd, @mode (check for setuid), @dirrm, @exec, and @unexec directives, and/or use the pkg_info(1) command to examine the installed package control files. OPTIONS
The following command line options are supported: pkg-name ... The named packages are deinstalled, wildcards can be used, see pkg_info(1). If no version is given, the one currently installed will be removed. If the -F flag is given, one or more (absolute) filenames may be specified and the package database will be consulted for the package to which the given file belongs. These packages are then deinstalled. -A Recursively remove all automatically installed packages that were needed by the given packages and are no longer required. Does not remove manually installed packages; see also the -R flag. -D If a deinstallation script exists for a given package, do not execute it. -F Any pkg-name given will be interpreted as pathname which is subsequently transformed in a (real) package name via the package data- base. That way, packages can be deleted by giving a filename instead of the package-name. -f Force removal of the package, even if a dependency is recorded or the deinstall script fails. This might break the package database; see pkg_admin(1) on how to repair it. -ff Force removal of the package, even if the package is marked as a preserved package. Note that this is a dangerous operation. See also the -k option. -K pkg_dbdir Override the value of the PKG_DBDIR configuration option with the value pkg_dbdir. -k Silently skip all packages that are marked as preserved. -N Remove the package's registration and its entries from the package database, but leave the files installed. Don't run any deinstall scripts or @unexec lines either. -n Don't actually deinstall a package, just report the steps that would be taken. -O Only delete the package's entries from the package database; do not touch the package or its files itself. -P destdir Prefix all file and directory names with destdir. For packages without install scripts this has the same behavior as using chroot(8). -p prefix Set prefix as the directory in which to delete files from any installed packages which do not explicitly set theirs. For most pack- ages, the prefix will be set automatically to the installed location by pkg_add(1). -R Recursively remove all packages that were needed by the given packages and are no longer required. This option overrides the -A flag. -r Recursively remove all packages that require one of the packages given. -V Print version number and exit. -v Turn on verbose output. TECHNICAL DETAILS
pkg_delete does pretty much what it says. It examines installed package records in <PKG_DBDIR>/<pkg-name>, deletes the package contents, and finally removes the package records. If a package is required by other installed packages, pkg_delete will list those dependent packages and refuse to delete the package (unless the -f option is given). If a package has been marked as a preserved package, it will not be able to be deleted (unless more than one occurrence of the -f option is given). If a filename is given instead of a package name, the package of which the given file belongs to can be deleted if the -F flag is given. The filename needs to be absolute, see the output produced by the pkg_info(1) -aF command. If a deinstall script exists for the package, it is executed before and after any files are removed. It is this script's responsibility to clean up any additional messy details around the package's installation, since all pkg_delete knows how to do is delete the files created in the original distribution. The deinstall script is called as: deinstall <pkg-name> VIEW-DEINSTALL before removing the package from a view, and as: deinstall <pkg-name> DEINSTALL before deleting all files and as: deinstall <pkg-name> POST-DEINSTALL after deleting them. Passing the keywords VIEW-DEINSTALL, DEINSTALL, and POST-DEINSTALL lets you potentially write only one program/script that handles all aspects of installation and deletion. All scripts are called with the environment variable PKG_PREFIX set to the installation prefix (see the -p option above). This allows a package author to write a script that reliably performs some action on the directory where the package is installed, even if the user might have changed it by specifying the -p option when running pkg_delete or pkg_add(1). The scripts are also called with the PKG_METADATA_DIR environment variable set to the location of the +* meta-data files, and with the PKG_REFCOUNT_DBDIR environment variable set to the location of the package reference counts database directory. If the -P flag was given to pkg_delete, PKG_DESTDIR will be set to destdir. ENVIRONMENT
See pkg_install.conf(5) for options, that can also be specified using the environment. SEE ALSO
pkg_add(1), pkg_admin(1), pkg_create(1), pkg_info(1), pkg_install.conf(5) pkgsrc(7) AUTHORS
Jordan Hubbard most of the work John Kohl refined it for NetBSD Hubert Feyrer NetBSD wildcard dependency processing, pkgdb, recursive "down" delete, etc. Joerg Sonnenberger Rewrote most of the code to compute correct order of deinstallation and to improve error handling. BSD
January 20, 2010 BSD
All times are GMT -4. The time now is 12:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy