Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

delete using joins in Oracle 10g

921312Apr 18 2012 — edited Apr 19 2012
Hi All

I am trying to delete rows from a table by comparing the criteria required with the rows in different tables..

The select statement below works fine...But when I use it for delete as shown in the subsequent SQL statement it errors out stating "SQL Command not properly ended"

Can anybody provide suggestions?....
----------------

This works fine


select rp.emplid,rp.empl_rcd,rp.dur,rp.punch_type,dt.dur,
TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') AS PUNCH_TIME
from
ps_tl_rptd_time rp
join ps_hd_dt_end_tmp4 dt on (rp.emplid = dt.emplid and rp.dur = dt.dur +1 AND(rp.punch_time = dt.PUNCH_TIME_8
or rp.punch_time = dt.PUNCH_TIME_7
or rp.punch_time = dt.PUNCH_TIME_6
or rp.punch_time = dt.PUNCH_TIME_5
or rp.punch_time = dt.PUNCH_TIME_4
or rp.punch_time = dt.PUNCH_TIME_3
or rp.punch_time = dt.PUNCH_TIME_2) )
join ps_fo_empl_xref fo on (rp.emplid = fo.emplid and rp.empl_rcd = fo.empl_rcd and dt.pbm_asgn_id = fo.pbm_asgn_id)
and TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') BETWEEN '00.00.00.000000' AND '11.59.59.000000'
--------------------

While this below one doesnt work.....

delete from
ps_tl_rptd_time rp
join ps_hd_dt_end_tmp4 dt on (rp.emplid = dt.emplid and rp.dur = dt.dur +1 AND(rp.punch_time = dt.PUNCH_TIME_8
or rp.punch_time = dt.PUNCH_TIME_7
or rp.punch_time = dt.PUNCH_TIME_6
or rp.punch_time = dt.PUNCH_TIME_5
or rp.punch_time = dt.PUNCH_TIME_4
or rp.punch_time = dt.PUNCH_TIME_3
or rp.punch_time = dt.PUNCH_TIME_2) )
join ps_fo_empl_xref fo on (rp.emplid = fo.emplid and rp.empl_rcd = fo.empl_rcd)
where dt.pbm_asgn_id = fo.pbm_asgn_id and
TO_CHAR(CAST((rp.PUNCH_TIME) AS TIMESTAMP),'HH24.MI.SS.FF') BETWEEN '00.00.00.000000' AND '11.59.59.000000'
;
This post has been answered by Stew Ashton on Apr 18 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2012
Added on Apr 18 2012
8 comments
29,867 views