delete using joins in Oracle 10g
921312Apr 18 2012 — edited Apr 19 2012Hi 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'
;