Solved

UNIX SQL script delete

Posted on 2007-11-29
5
979 Views
Last Modified: 2013-12-18
I have a UNIX shell script that calls an sql file.  In the sql file I have:

delete from tableA where fw_insert_date < sysdate-30
delete from   tableB  where insert_date < sysdate-30
delete from   tableC  where insert_date < sysdate-30
commit

The shell script calls the SQL script but nothing happens. What do I need to add to the SQL file to make this work?
0
Comment
Question by:jjc_mn
5 Comments
 
LVL 14

Accepted Solution

by:
GGuzdziol earned 500 total points
ID: 20376395
Semicolon after each individual statement? If this is not the case - please show script's and sql file's actual code...
delete from tableA where fw_insert_date < sysdate-30;

delete from tableB where insert_date < sysdate-30;

delete from tableC where insert_date < sysdate-30;

commit;

Open in new window

0
 
LVL 11

Expert Comment

by:mohammadzahid
ID: 20376479
Just to be on the safe side if your database is production...

I recommed that you take out commit from your script and add SQL statement to give you row count before and after the delete with output (spool file). Verify deleted rows and then issue commit outside of the script.

0
 
LVL 31

Expert Comment

by:awking00
ID: 20377141
What does the shell script look like?
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 20380393
does the sql statements work if you run them in the sql> prompt directly.

If yes, then may be missing ; is the only thing which i can think of.

If no, then first you need to check why there are not working ( resolve the errors if you are getting any ).

Thanks
0
 

Author Closing Comment

by:jjc_mn
ID: 31411760
The semi-colons were what I was missing. Thanks all.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now