Skip to Main Content

Oracle Database Discussions

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Auto Increment

430789Oct 13 2004 — edited Oct 13 2004
I know that Oracle doesn't support a field of data type auto_increment and that you can simulate this behavior by creating a sequence that is updated by a trigger every time a table is updated...but how do you handle a field that sometimes should be auto incremented and sometimes has a value directly inserted into it. I have the following:

CREATE TABLE tblComponents (
id INT NOT NULL,
name VARCHAR(100) NOT NULL,
PRIMARY KEY (id),
);

CREATE SEQUENCE tblComponents_Seq
START WITH 1
INCREMENT BY 1
NOMAXVALUE;

CREATE TRIGGER tblComponents_Trig
BEFORE INSERT ON tblComponents
FOR EACH ROW
BEGIN
SELECT tblComponents_Seq.nextval INTO :new.id from DUAL;
END;
/


This works great as long as I never directly insert an id into tblComponents but sometimes I need to and the sequence is not updated...so when the sequence finally gets to the id number I just inserted it collides. How do I insert the highest id in tblComponents +1 in a trigger?

Thanks,
Jim

Comments

Mannamal-Oracle
We are planning direct SPARQL support, but for now the options are exactly what you say - use products from partners like Metatomix or TopQuadrant who support a SPARQL interface to a backend Oracle RDF data store.

We also have an integration with the open source Jena, through which SPARQL queries can be issued against an Oracle RDF store. The integration for Jena requires the Oracle Jena Adaptor (see 586398 for downloading and using the adaptor).

Melli
222378
Thank you for the reponse.
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 10 2004
Added on Oct 13 2004
5 comments
493 views