|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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..... |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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:
|
|
#4
|
|||
|
|||
|
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); |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Deleting from multiple tables.... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|