Çhristofer Parra
Çhristofer Parra

Reputation: 27

INSERT error in Oracle

I am working with oracle (with Toad) but when I try to execute this query

INSERT INTO KEYUSER(NAME) VALUES(UNAME) WHERE ID = 1;

I get this error:

SQL command not properly ended. Found 'WHERE' expecting ;-or- LOG -or- RETURN RETURNING

What is wrong? Regards.

Upvotes: 0

Views: 966

Answers (3)

Gordon Linoff
Gordon Linoff

Reputation: 1269443

Presumably, you intend an UPDATE rather than INSERT:

UPDATE KEYUSER
    SET NAME = UNAME
    WHERE ID = 1;

Sometimes new users of SQL get confused between INSERT and UPDATE. INSERT inserts new rows into a table. UPDATE changes values in existing rows. The confusion is become some people interpret INSERT as "inserting new values into a row".

Upvotes: 0

Zaynul Abadin Tuhin
Zaynul Abadin Tuhin

Reputation: 32003

General Insert statement is like below

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);   

So in your case you have to remove where clause from your statement and query will be like below

INSERT INTO KEYUSER(NAME) VALUES('UNAME');

Upvotes: 1

codeLover
codeLover

Reputation: 2592

You can never use where clause in insert statement. It does not make any sense to have it while you are simply trying to insert a row.

Upvotes: 3

Related Questions