Insert into table returning primary key (auto number) in resultset
663506Oct 13 2008 — edited Oct 13 2008Hi,
I'm connecting to Oracle 10g via JDBC (ojdbc14.jar).
My SQL statement is as follows:
INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test');
SELECT Student_studentId_SEQ.NEXTVAL FROM DUAL;
Fyi -The Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.
What the above will do (from the Java app point of view) is to create a Student record and automatically select the student ID so that the student ID can be accessed via the resultset in Java.
I'm getting error "ORA-00911: invalid character". Can you please help?
Regards,
Jason
Edited by: user10394130 on Oct 13, 2008 2:40 AM