[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

UNIX SQL script delete

Posted on 2007-11-29
5
Medium Priority
?
1,012 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 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