antonpug
antonpug

Reputation: 14286

Why is my SQL failing? (ORA-00933: SQL command not properly ended)

Why is my SQL failing? I think it s formatted correctly, but it throws an error at me.

    INSERT INTO NBOT_USERS
       (ID,LAST_NAME,FIRST_NAME)
    VALUES
       (1002, 'Smith', 'John')
    WHERE 1002 NOT IN (SELECT IT_ID FROM NBOT_USERS);

Upvotes: 0

Views: 688

Answers (2)

dani herrera
dani herrera

Reputation: 51645

Inserting Values with a Subquery: Example

INSERT INTO bonuses
   SELECT employee_id, salary*1.1 
   FROM employees
   WHERE commission_pct > 0.25 * salary;

With your schema:

INSERT INTO NBOT_USERS (ID,LAST_NAME,FIRST_NAME)
Select 1002, 'Smith', 'John' 
  From dual
  WHERE 1002 NOT IN (SELECT  FROM NBOT_USERS);

Upvotes: 1

Marc B
Marc B

Reputation: 360572

Insert queries do not have where clauses, unless you're doing INSERT ... SELECT FROM, in which case there can be a where clause in the SELECT portion.

Upvotes: 4

Related Questions