I am working on a .Net application using C#.
I am using System.Data.OracleClient and inline sql queries to connect to Oracle database.
I need to insert new records from the application in the database.The database tables have autoincrement enabled on their primary keys.
Can anyone please help me with the code syntax to do this...?
livehed
Member
55 Points
24 Posts
Retrieving identity/autonumber values from Oracle database
May 04, 2006 05:34 PM|LINK
I am working on a .Net application using C#.
I am using System.Data.OracleClient and inline sql queries to connect to Oracle database.
I need to insert new records from the application in the database.The database tables have autoincrement enabled on their primary keys.
Can anyone please help me with the code syntax to do this...?
Thanks in advance...!
Regards,
livehed
dweezil
Participant
1873 Points
395 Posts
Re: Retrieving identity/autonumber values from Oracle database
May 04, 2006 07:26 PM|LINK
CREATE SEQUENCE my_seq
MINVALUE 1
START WITH 1
INCREMENT BY 1;
Now when you want to insert a new row:
INSERT INTO my_table
VALUES(my_seq.nextval,next_val1, next_val2);
See the Oracle documentation for more details.
SELECT * FROM users WHERE clue = 'yes';
Records found: 0