Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old August 25th, 2004, 10:26 AM
newbiet newbiet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 newbiet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Deleting from multiple tables....

DELETE from tinfo_req_hist i, tquery_text_hist q
where i.caller_rec_no=q.caller_rec_no
and i.info_req_no=q.info_req_no
and i.caller_rec_no=8888
and info_req_start_time='19-Aug-2004';

I am getting the error ora-00933 sql command not properly ended.

I have even tried to put a select in it:

DELETE (select * from tinfo_req_hist i, tquery_text_hist q
where i.caller_rec_no=q.caller_rec_no
and i.info_req_no=q.info_req_no
and i.caller_rec_no=8888
and info_req_start_time='19-Aug-2004');

and then I get the error

ora-01752 cannot delete from view without exactly one key-preserved table

Please help me.....

Reply With Quote
  #2  
Old August 25th, 2004, 11:26 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
You can delete records from a table at a time the only exception with the parent and child tables, if you have defined the ON DELETE CASCADE keyword with reference key in child record then it means associated child record(s) must be deleted when a parent record is deleted.

now how can you delete it with searching cirteria with other table, take a look:

DELETE from tinfo_req_hist i
WHERE EXISTS ( SELECT 1 from tquery_text_hist q
where i.caller_rec_no=q.caller_rec_no
and i.info_req_no=q.info_req_no
and i.caller_rec_no=8888
and info_req_start_time='19-Aug-2004')
/

Now remember this is an example only, not gurantee that the query will perform 100% correctly as you wanted, you have to make certain changes in it.

Reply With Quote
  #3  
Old September 6th, 2004, 04:49 AM
Hi2Sunita Hi2Sunita is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 Hi2Sunita User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi

You can just try out the follwoing query.but the earlier reply which u got is very right.Just check whether the folowing query works or ont.

delete from tinfo_req_hist i
where i.caller_rec_no=8888
and i.info_req_start_time='19-Aug-2004'
and i.caller_rec_no in (select caller_rec_no from tquery_text_hist);




Quote:
Originally Posted by shafique
You can delete records from a table at a time the only exception with the parent and child tables, if you have defined the ON DELETE CASCADE keyword with reference key in child record then it means associated child record(s) must be deleted when a parent record is deleted.

now how can you delete it with searching cirteria with other table, take a look:

DELETE from tinfo_req_hist i
WHERE EXISTS ( SELECT 1 from tquery_text_hist q
where i.caller_rec_no=q.caller_rec_no
and i.info_req_no=q.info_req_no
and i.caller_rec_no=8888
and info_req_start_time='19-Aug-2004')
/

Now remember this is an example only, not gurantee that the query will perform 100% correctly as you wanted, you have to make certain changes in it.

Reply With Quote
  #4  
Old September 6th, 2004, 11:39 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
The following query should produce the same result:

delete from tinfo_req_hist i
where i.caller_rec_no=8888
and i.info_req_start_time='19-Aug-2004'
and i.caller_rec_no in (select caller_rec_no from tquery_text_hist);

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Deleting from multiple tables....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway