| delete statement with inner join [message #499232] |
Mon, 14 March 2011 04:06  |
 |
swapnabpnn
Messages: 96 Registered: December 2010
|
Member |
|
|
Hi,
I am trying to run following sql query,but it is throwing following error.Could any one please correct the query.
SQL> delete from b$gc_count_temp a INNER JOIN COMPLEMENTS ON b$gc_count_temp.CON
NECTION_ID_TEMP=COMPLEMENTS.feature_conn_id
2 WHERE a.current_designation is null and a.current_low is null and a.current
_high is null;
delete from b$gc_count_temp a INNER JOIN COMPLEMENTS ON b$gc_count_temp.CONNECTI
ON_ID_TEMP=COMPLEMENTS.feature_conn_id
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
Thanks..........
|
|
|
|
|
|
|
|
| Re: delete statement with inner join [message #499239 is a reply to message #499237] |
Mon, 14 March 2011 04:35   |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
It would help if you would provide a test case including create table and insert statements for sample data and the result that you want based on that data. You can delete from a join condition, but it needs to be within a select statement and there must be a key-preserved table. Please see the demonstration below.
SCOTT@orcl_11gR2> create table b$gc_count_temp
2 (connection_id_temp number primary key,
3 current_designation number,
4 current_low number,
5 current_high number)
6 /
Table created.
SCOTT@orcl_11gR2> insert into b$gc_count_temp values
2 (1, null, null, null)
3 /
1 row created.
SCOTT@orcl_11gR2> insert into b$gc_count_temp values
2 (2, 3, 4, 5)
3 /
1 row created.
SCOTT@orcl_11gR2> create table complements
2 (feature_conn_id number primary key)
3 /
Table created.
SCOTT@orcl_11gR2> insert into complements values (1)
2 /
1 row created.
SCOTT@orcl_11gR2> insert into complements values (2)
2 /
1 row created.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> delete from
2 (select *
3 from b$gc_count_temp a
4 INNER JOIN COMPLEMENTS
5 ON a.CONNECTION_ID_TEMP=COMPLEMENTS.feature_conn_id
6 WHERE a.current_designation is null
7 and a.current_low is null
8 and a.current_high is null)
9 /
1 row deleted.
SCOTT@orcl_11gR2> select * from b$gc_count_temp
2 /
CONNECTION_ID_TEMP CURRENT_DESIGNATION CURRENT_LOW CURRENT_HIGH
------------------ ------------------- ----------- ------------
2 3 4 5
1 row selected.
SCOTT@orcl_11gR2> select * from complements
2 /
FEATURE_CONN_ID
---------------
1
2
2 rows selected.
SCOTT@orcl_11gR2>
|
|
|
|
|
|