Solved

UNIX SQL script delete

Posted on 2007-11-29
5
980 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 32

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

929 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

21 Experts available now in Live!

Get 1:1 Help Now