Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

UNIX SQL script delete

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

Suggested Solutions

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

861 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