Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert into table returning primary key (auto number) in resultset

663506Oct 13 2008 — edited Oct 13 2008
Hi,

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
This post has been answered by Karthick2003 on Oct 13 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2008
Added on Oct 13 2008
15 comments
9,458 views