Delete from table inner join - ORA-00933: SQL command not properly ended
<p>Aim is to insert records into a table only if same records donot exists in same table.
So, I stored values of that table in a Cursor like this: -</p>

<pre><code>cursor note_data is
        select  note_s.nextval, i_user_book_id, i_course_user_id, book_edition_id, book_id, n.role_type_id, page_id, book_page_number, 
                        xcoord, ycoord, width, height, share_across_courses, sysdate, i_user_id, description, share_with_students,text
        from    note n, course_user cu
        where   n.course_user_id = cu.course_user_id
        and     cu.course_id = i_from_course_id;
</code></pre>

<p>Now, I will delete the records from the table using inner join like this -</p>

<pre><code>delete n 
from note n 
inner join course_user cu 
on n.course_user_id = cu.course_user_id 
where cu.course_id = i_from_course_id;
</code></pre>

<p>While executing this delete statement, I am getting error - <strong><em>'ORA-00933: SQL command not properly ended'</em></strong></p>

<p>If I will be able to delete the records from table, I will insert same records from cursor data into the same table using this code :-</p>

<pre><code>FOR notecopy IN note_data LOOP
    insert into note (note_id, user_book_id, course_user_id, book_edition_id, book_id, role_type_id, page_id, book_page_number, 
                            xcoord, ycoord, width, height, share_across_courses, date_created, date_updated, created_by, updated_by, description, share_with_students,text)
    values (note_s.nextval, notecopy.i_user_book_id, notecopy.i_course_user_id, notecopy.book_edition_id, notecopy.book_id, notecopy.role_type_id, notecopy.page_id, notecopy.book_page_number, 
                            notecopy.xcoord, notecopy.ycoord, notecopy.width, notecopy.height, notecopy.share_across_courses, sysdate, sysdate, notecopy.i_user_id, notecopy.i_user_id, notecopy.description, notecopy.share_with_students, notecopy.text);
END LOOP; 
</code></pre>

<p>My target is to insert records into a table only if same records donot exists in same table. </p>

<p>Please guide how to deal with the delete statement error as well as suggest am I following correct approach to achieve the target. If not, Please suggest some alternative way as well.</p>

<p>Thanks</p>