auwall
auwall

Reputation: 763

Problem inserting row into oracle

Any idea why this doesn't work?

The name of the table is TESTTABLE with just one column called TEST_COLUMN which is the primary key. I'm sure it is something dumb, but thought i'd ask. I'm already connected to the database so i didn't worry about providing that code

Statement statement = connection.createStatement();
String test = "test";
statement.executeUpdate("INSERT INTO TESTTABLE (TEST_COLUMN) VALUES (" + test + ")");

gives me this error

ORA-00984: column not allowed here

Upvotes: 1

Views: 650

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171549

I am assuming that is a varchar column, so try:

statement.executeUpdate("INSERT INTO TESTTABLE (TEST_COLUMN) VALUES ('" + test + "')");

Note the single quotes around the data.

Upvotes: 5

Related Questions