AUTO Increment on TABLE or TRIGGER

I have a table that I created. I want the first column in the table to auto increment. Some of the examples I have seen create a sequence, and then do the update on a trigger?
Is is possible to just start with 1 and increment by one when something is inserted into the table in the CREATE or ALTER Table syntax?
Or Do I have to create a sequence, and trigger for this?

I have already created a trigger for this table. I am doing an insert.
IF UPDATE THEN
  INSERT INTO EQUIPMENT_USER_DATA_AUDIT (
    equipment_id,
    old_cpe_status,
    new_cpe_status,
    cpe_status_changed,
    old_ne_status,
    new_ne_status,
    ne_status_changed,
    date_modified,
    modifiers_name)
VALUES (
    :new.equipment_id,
    :old.cpe_status,
    :new.cpe_status,
    (CASE WHEN :old.cpe_status = :new.cpe_status
           THEN 'N'
           ELSE 'Y'
     END),
    :old.ne_status,
    :new.ne_status,
    (CASE WHEN :old.ne_status = :new.ne_status
           THEN 'N'
           ELSE 'Y'
     END),
    SYSDATE,
    SYS_CONTEXT ('USERENV','CURRENT_SCHEMA'));
   END IF;Do I need to declare the first column in my insert? which is named seq_id?

Similar Messages

  • Hibernate data insertion not working with oracle auto increment

    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pojo.Example
    at org.hibernate.id.Assigned.generate(Assigned.java:33)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
    at hibernetsample.Main.main(Main.java:30)

    >
    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.Assigned
    >
    That is because you are using the hibernate 'assigned' generator which, by definition
    >
    lets the application to assign an identifier to the object before save() is called.
    This is the default strategy if no <generator> element is specified.
    >
    For your use case you can use the 'sequence' generator.
    The valid generator options and one way to use a sequence generator is shown in this article
    http://www.hibernate-training-guide.com/identifiers-generators.html
    The hibernate section of this article also uses a trigger with sequence generator
    http://blog.lishman.com/2009/02/auto-generated-primary-keys-in-oracle.html
    You should check the hibernate documention and tutorial for examples or search 'hibernate generator sequence example'

  • Not authorised to have auto increment trigger on server

    Hello all. I need a few triggers set up, I have no problems setting up sequences and "before insert" triggers on my home PC setup but on the live server where I study I do not have the authority.
    I got around this before by using Forms so I set the trigger at Form level.
    I am developing a DB system that will at some stage in the future use Forms, but for now it will use HTML forms via a web browser.
    I need to have the primary key for user accessible tables to be auto incremented (on the server where I study), but how can get around the authority issue ??
    Any ideas are extremely welcome !!

    Hello all - yeah I am on a course. I too have no idea why they will not allow the students to create triggers at table level.
    The 1st system I developed at home I had auto incremented primary keys. It was using Oracle Forms as the front end. Because I am the admin on my home setup I didn't have any problems.
    When I went to the course site to implement exactly what I had at home (which worked 100% properly) inserting data via the forms was not working. I had no idea why. the lecturer guy took a look at my code and told me its because of the trigger, I do not have authority to create triggers on the server.
    "create or replace trigger cust_trg
    before insert on customer
    for each row
    begin
    select cust_seq.nextval into :new.cust_id
    from dual;
    end;"
    The above code works fine on my home PC. I used Pre Insert triggers on the block on the Form instead to get around the problem (I presumed it was because they wanted us to learn Forms more thoroughly).
    This next project does not involve forms but they will not change my access rights so I don't have a clue as to how to get an auto incremented primary key whilst using a HTML form.
    Kevin

  • Auto Increment ID Field Table in the Oracle Database (insert new record)

    I have been using the MySQL. And the ID field of the database table is AUTO INCREMENT. When I insert a new record into a database table, I can have a statement like:
       public void createThread( String receiver, String sender, String title,
                                 String lastPostMemberName, String threadTopic,
                                 String threadBody, Timestamp threadCreationDate,
                                 Timestamp threadLastPostDate, int threadType,
                                 int threadOption, int threadStatus, int threadViewCount,
                                 int threadReplyCount, int threadDuration )
                                 throws MessageDAOSysExceptionand I do not have to put the ID variable in the above method. The table will give the new record an ID number that is equivalent to the ID number of the last record plus one automatically.
    Now, I am inserting a new record into an Oracle database table. I am told that I cannot do what I am used to doing with the MySQL database.
    How do I revise the createThread method while I have no idea about what the next sequence number shall be?

    I am still very confused; in particular, the Java part. Let me try again.
    // This part is for the database table creation
    -- Component primary key sequence
    CREATE SEQUENCE dhsinfo_page_content_seq
        START WITH 0;
    -- Trigger for updating the Component primary key
    CREATE OR REPLACE TRIGGER DHSInfoPageContent_INSERT_TRIGGER
        BEFORE INSERT ON DHSInfoPageContent //DHSInfoPageContent is the table name
        FOR EACH ROW WHEN (new.ID IS NULL) // ID is the column name for auto increment
        BEGIN
            SELECT dhsinfo_page_content_seq.Nextval
            INTO :ID
            FROM DUAL;
        END;/I am uncertain what to do with my Java code. (I have been working with the MySQL. Changing to the Oracle makes me very confused.
       public void updateContent( int groupID, String pageName, int componentID,
                                  String content, Timestamp contentCreationDate )
                                   throws contentDAOSysException
       // The above Java statement does not have a value to insert into the ID column
       // in the DHSInfoPageContent table
          Connection conn = null;
          PreparedStatement stmt = null;
          // what to do with the INSERT INTO below.  Note the paramether ID.
          String insertSQL = "INSERT INTO DHSInfoPageContent( ID, GroupID, Name, ComponentID, Content, CreationDate ) VALUES (?, ?, ?, ?, ?, ?)";
          try
             conn = DBConnection.getDBConnection();
             stmt = conn.prepareStatement( insertSQL );
             stmt.setInt( 1, id ); // Is this Java statement redundant?
             stmt.setInt( 2, groupID );
             stmt.setString( 3, pageName );
             stmt.setInt( 4, componentID );
             stmt.setString( 5, content );
             stmt.setTimestamp( 6, contentCreationDate );
             stmt.executeUpdate();
           catch
           finally

  • How to insert into table when ID auto increment?

    I have a table Employee with EmloyeeID, EmployeeName, Email...
    When i design table in database, i created a Sequence and then Trigger for EmployeeID to auto increment.
    Now in ADF, actually in my web form: I don't want enter values for EmployeeID to insert into table,
    but still error : required for EmployeeID...
    how can i do it? Thanks

    User,
    Always mention your JDev version every time you start a new thread.
    Check this out : Andrejus Baranovskis Blog: How To Implement Gapless Sequence in ADF BC
    -Arun

  • Auto Increment column in database table

    Hello experts, I am using oracle 11g database at windows 7.I have to create a sequence object and a table with an auto increment ID column.For this I have created a trigger before insert to select next sequence from a sequence object. It works well but Now I have the current sequence is 7 and there are 6 records inserted in table. Now I delete two records.Thus I have only 5 records in table but my current sequence is still 7.So if I put it in id column then a new record will be inserted in table with 7 ID number after 5th ID number.I want this record should be inserted with 6 Id number. For this I tried to not use sequence object.I tried a pl/sql trigger before insert, which will count the all records in table and after increment i put it in ID column to insertion....Is this a professional way..? thank You regards aaditya

    979801 wrote:
    Hello experts, I am using oracle 11g database at windows 7.I have to create a sequence object and a table with an auto increment ID column.For this I have created a trigger before insert to select next sequence from a sequence object. It works well but Now I have the current sequence is 7 and there are 6 records inserted in table. Now I delete two records.Thus I have only 5 records in table but my current sequence is still 7.So if I put it in id column then a new record will be inserted in table with 7 ID number after 5th ID number.I want this record should be inserted with 6 Id number. For this I tried to not use sequence object.I tried a pl/sql trigger before insert, which will count the all records in table and after increment i put it in ID column to insertion....Is this a professional way..? thank You regards aaditya
    Sequences only guarantee unique numbers.  You cannot (and should not) attempt to create gapless sesquences.  That's not how oracle works and will not scale to a multi user application.
    Imagine two people try to insert records at the same time (and have yet to commit), the trigger you create will count the number of records and determine there are 5 records, so assign the next number of 6, for both people who are inserting records.  The first person to commit will get their data saved, and assuming you have a unique constriaint on that id, the second person will raise a duplicate key on insert or suchlike error.
    Gapless sequential numbers are not appropriate to multi-user environments.  Such requirements are often given by managers or business people who do not understand the technology.
    Think of it in terms of a real world office, but with people using a paper system instead of a computer.  The only way you can try to guarantee people get the next number and also re-use numbers that have been deleted is to have a single place where each person in the office goes to, to fetch the next number, and they have to queue up behind each other to get the next one off the list.  But if someone has removed an old record, they've got to wait in the same queue to go and put that number back in the pot for someone else to use.  It just doesn't work, even in a manual system.  Yes, people can guarantee that they're only getting unique numbers that nobody else is using, but they cannot guarantee that they are reusing and filling gaps etc.  It's an unrealistic expectation.

  • Auto increment trigger

    I have a table with an index and two other columns. The first column is called index.
    What I would like to do is to auto increment the index column on every insertion. I have read some of the documentation and can't make sense of what I am trying to do. Please point me to an example.
    WBR

    I tried these 3 statements to create a auto update column:
    CREATE TABLE TIME_TABLE (
    RECORD_NUM INTEGER NOT NULL,
    DATE_FIELD DATE,
    DESCRIPTION VARCHAR(1000));
    CREATE SEQUENCE TIME_SEQ START WITH 1 INCREMENT BY 1;
    CREATE OR REPLACE
    TRIGGER TIME_TRIGGER BEFORE INSERT ON TIME_TABLE
    FOR EACH ROW
    BEGIN
    SELECT TIME_SEQ.NEXTVAL INTO :NEW.RECORD_NUM FROM DUAL;
    END
    When I execute an insert statement I get the following error:
    An error was encountered performing the requested operation:
    ORA-04098: the trigger ‘TIME.TIME_TRIGGER’ is invalid and failed re-validation.
    So my question is what is wrong with the three statements. I would appreciate some help.

  • Insert to 2 Tables and Auto-Increment

    I applied the Insert To 2 Tables Wizard and then added an Auto-Increment
    behavior to auto increment a field in the master table. BUT - I also
    need to auto-increment a field in the detail table. The AutoIncrement
    behavior only offers fields for the master table. So - how do I
    auto-increment the detail table?
    I know I could create a custom trigger - but how do you grab the primary
    key from the DETAIL table?
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

    Got it. Advanced tab of the AutoIncrement server behavior - remove the
    master table and add the detail table. Then return to basic tab and add
    the appropriate field.
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

  • Trigger Bad Bind Value Auto Increment

    I am new to the Oracle world and am trying to make the switch from MySQL so my apologies if this seems like a silly question.
    I am trying to figure out what is wrong with my trigger code. Basically , I am trying to create an auto-increment solution using some example code I found on the Internet.
    I have a fairly simple table structure:
    CREATE TABLE "CIMS"."computerSoftware"
    ( "computerSoftware_id" NUMBER(11,0),
    "cid" NUMBER(11,0) DEFAULT 0 NOT NULL ENABLE,
    "publisher" VARCHAR2(100 CHAR) DEFAULT NULL,
    "name" VARCHAR2(100 CHAR) DEFAULT NULL,
    "version" VARCHAR2(100 CHAR) DEFAULT NULL,
    "serialNumber" VARCHAR2(100 CHAR) DEFAULT NULL,
    "unlimited" NUMBER(4,0) DEFAULT 0,
    "copies" NUMBER(9,0) DEFAULT 1 NOT NULL ENABLE,
    "master" NUMBER(4,0) DEFAULT 0,
    PRIMARY KEY ("computerSoftware_id")
    My Trigger looks like this:
    CREATE OR REPLACE TRIGGER "CIMS"."TR_CompSoftware_ID"
    BEFORE INSERT ON CIMS."computerSoftware"
    REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    BEGIN
    IF (:new.computerSoftware_id IS NULL) then
    SELECT S_CompSoftware_ID.NEXTVAL
    INTO :new.computerSoftware_id
    FROM dual;
    end IF;
    END;
    And finally, here is my sequence:
    CREATE SEQUENCE "CIMS"."S_CompSoftware_ID" MINVALUE 1
    MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 10 NOORDER NOCYCLE
    When I try to save the trigger I receive the following error:
    PLS-00049: bad bind variable 'NEW.COMPUTERSOFTWARE_ID'
    Any help is much appreciated!
    Tom

    And, this is the way - you can rectify this problem ->
    satyaki>
    satyaki>drop table "computerSoftware";
    Table dropped.
    Elapsed: 00:00:00.92
    satyaki>
    satyaki>CREATE TABLE computerSoftware
      2  (  
      3      computerSoftware_id NUMBER(11,0),
      4      cid NUMBER(11,0) DEFAULT 0 NOT NULL ENABLE,
      5      publisher VARCHAR2(100 CHAR) DEFAULT NULL,
      6      name VARCHAR2(100 CHAR) DEFAULT NULL,
      7      version VARCHAR2(100 CHAR) DEFAULT NULL,
      8      serialNumber VARCHAR2(100 CHAR) DEFAULT NULL,
      9      un_limited NUMBER(4,0) DEFAULT 0,  -- Need to change the name of your column due to use of reserve word
    10      copies NUMBER(9,0) DEFAULT 1 NOT NULL ENABLE,
    11      master NUMBER(4,0) DEFAULT 0,
    12     constraints pk_cid PRIMARY KEY (computerSoftware_id)
    13   );
    Table created.
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>CREATE SEQUENCE S_CompSoftware_ID MINVALUE 1
      2  MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 10 NOORDER NOCYCLE;
    Sequence created.
    Elapsed: 00:00:00.05
    satyaki>
    satyaki>
    satyaki>CREATE OR REPLACE TRIGGER TR_CompSoftware_ID
      2  BEFORE INSERT ON computerSoftware
      3  REFERENCING OLD AS OLD NEW AS NEW
      4  FOR EACH ROW
      5  BEGIN
      6    IF (:new.computerSoftware_id IS NULL) then
      7        SELECT S_CompSoftware_ID.NEXTVAL
      8        INTO :new.computerSoftware_id
      9        FROM dual;
    10    end IF;
    11  END;
    12  /
    Trigger created.
    Elapsed: 00:00:00.98
    satyaki>
    satyaki>insert into computerSoftware(cid,publisher,name,version,serialNumber,un_limited,copies,master)
      2     values(1,'ABP','SR','1.0.0.1','1.4.3',88,7,9);
    1 row created.
    Elapsed: 00:00:00.14
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.05
    satyaki>
    satyaki>
    satyaki>select * from computerSoftware;
    COMPUTERSOFTWARE_ID        CID PUBLISHER                                                                                            NAME                                                                                                 VERSION                                                                       
                      1          1 ABP                                                                                                  SR                                                                                                   1.0.0.1                                                                       
    Elapsed: 00:00:00.05
    satyaki>Got me?
    Regards.
    Satyaki De.

  • Add auto increment column to trigger

    I want to add auto increment column to after insert trigger. so how can I do that?

    this is my query.
    Create Sequence Up_Seq
    Start With 1
    Increment By 1
    nomaxvalue;
    Create Or Replace Trigger Upf_Trig
    After Insert On members
    Referencing New As New
    For Each Row
    Begin
    Insert Into Upf_Kgl(Member_Id,Mem_Name,Nic,Division)
    Values (Up_Seq.Nextval
    *,:New.Mem_Name*
    *,:New.Nic*
    *,:New.Division);*
    end upf_trig;
    It's worked. but when inserting values to members table, there is an error.
    this is the error
    Error starting at line 21 in command:
    Insert Into Members(Mem_Name,Nic,Full_Name,Age,Sex,Mar_State,Birth_Date,Division,Religon)
    Values(
    *'IA Nawagamuwa'*
    *,'883324356V'*
    *,'Isuru Aravinda Nawagamuwa'*
    *,'22'*
    *,'Male'*
    *,'Single'*
    *,'21-Dec-88'*
    *,'kgl'*
    *,'Buddhist')*
    Error report:
    SQL Error: ORA-00001: unique constraint (SYSTEM.SYS_C004077) violated
    ORA-06512: at "SYSTEM.UPF_TRIG", line 2
    ORA-04088: error during execution of trigger 'SYSTEM.UPF_TRIG'
    *00001. 00000 - "unique constraint (%s.%s) violated"*
    **Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.*
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    **Action: Either remove the unique restriction or do not insert the key.*

  • Auto Increment of Primary Field in Table Maintainance

    Hi,
    We want to give an Auto increment to the Primary Key, when ever the table is updated/inserted with a new record. How to get the value updated????
    For Eg,
    Table ZTEST Contains     MANDT, ITEM,   EBELN.
    It should have the values 800    001   000977
    And when the next record is created, the ITEM value should be Automatically get the value 002.. and so on for every Record.
    Pls do let me know if any other details is reqd.
    Thanx in Advance.
    Ajaz

    Dear Syed,
       You can do many things in table maintenance screen like validation of some field, making some field required or displayed etc.
       For auto increment you have to use Number-Ranges. FM NUMBER_GET_NEXT is helpful in this case.
       Where to write the code??? The Function-Group you have made. There will be includes. You can easily locate the place to write these codes.
       Caution point is that if you re-generate the table maintenance then all code will be gone.
    Regards,
    Deva.

  • How to use "Auto increment" in temp table Oracle

    Pleas tell me yaar,
    In MS Sql for Auto increment i am using like this "seqid int identity" for temp table
    t_seq_tbl table(seqid int identity,EVENT_SEQ_NO varchar(30))
    In oracle how to use....

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Update table column with same auto-increment value, via T-SQL stored procedure

    Good Evening to every one,
    I have a table 'Contracts' as we can see in the picture below (I exported my data on An Excel Spreadsheet). Table's primary key is 'ID' column.
    I am trying to create a stored procedure (i.e. updContractNum), through which I am going to update the 'Contract_Num' column, in every row where the values on Property_Code, Customer, Cust_Category and Amnt ARE EQUAL, as we can see in the schema above.
    The value of Contract_Num is a combination of varchar and auto_increment (integer). For example, the next value on 'Contract number' column will be 'CN0005' for the combination of 11032-14503-02-1450,00
    I' m trying to use CURSORS for this update but I am new in using cursors and I am stuck in whole process. I atttach my code below:
    CREATE PROCEDURE updContractNum
    AS
    --declare the variables
    DECLARE @CONTRACT_NUM VARCHAR(10); -- Contract Number. The value that will be updated on the table.
    DECLARE @CONTRACT INTEGER; -- Contract number, the auto increment section on contract number
    DECLARE @CONTR_ROW VARCHAR(200); -- Contract row. The row elements that will be using on cursor
    DECLARE CONTRACT_CURSOR CURSOR FOR -- Get the necessary fields from table
    SELECT PROPERTY_CODE, CUSTOMER, CUST_CATEGORY, AMNT
    FROM CONTRACTS;
    OPEN CONTRACT_CURSOR -- open a cursor
    FETCH NEXT FROM CONTRACT_CURSOR INTO @CONTR_ROW
    WHILE @@FETCH_STATUS = 0 -- execute the update, for every row of the tabl
    BEGIN
    --update Contract_Num, using the format coding : contract_number = 'CN' + 0001
    UPDATE CONTRACTS
    SET CONTRACT_NUM = 'CN'+@CONTRACT_NUM+1
    END
    CLOSE CONTRACT_CURSOR
    Thank you in advance!

    You dont need cursor
    You can simply use an update statement like this
    UPDATE t
    SET Contract_Num = 'CN' + RIGHT('00000' + CAST(Rnk AS varchar(5)),5)
    FROM
    SELECT Contract_Num,
    DENSE_RANK() OVER (ORDER BY Property_Code,Customer,Cust_category,Amnt) AS Rnk
    FROM table
    )t
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Attaching an Auto Incrementer to an existing table

    Hi!
    Have a few tables orders of records of which I need not to change and add an auto-increment sort of additional field to help in sort and manipulate the same. Any idea how to achieve the same???
    Thanx in advance,
    Best Regards, Faraz A Qureshi

    If you use SQL Server 2012 and onwards take a look ta SEQUENCE
    http://msdn.microsoft.com/en-us/library/ff878091.aspx
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Creating an auto incrementing field with CREATE TABLE from Java

    I'm using the "sun.jdbc.odbc.JdbcOdbcDriver" to get a connection towards an ODBC data source that's linked to a Access (.mdb) database.
    I've tried various combinations in my CREATE TABLE statement execution in order to create a table with an auto incrementing integer but neither of them work, not even the most obvious one:
    stmt.executeUpdate("CREATE TABLE mytable(uid integer AUTO_INCREMENT PRIMARY KEY);");
    I always get this runtime exception: *java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in field definition*; and AUTO_INCREMENT is the problem. I've tried all variations like AUTO, INCREMENT, AUTOINCREMENT and such, but nothing works.
    I've looked everywhere but couldn't find an answer to this. Thanks for the help.

    You used MySQL syntax. I think you agree with me that Access isn't a MySQL database. Either use MySQL with a real JDBC driver (recommended) or use Access syntax.
    That said, creating databases and tables using Java is a bad idea. The database and table must be already there. With Java you just do the usual table operations like select, insert, update and delete. Nothing more is needed.

Maybe you are looking for

  • Why cant i run my applet on JRE 1.6 but on JRE 1.5?

    Hello, I know this is a very basic problem, but i still cannot get a justified answer for this problem. Its like i have an applet which is compiled in JDk j2sdk1.4.2_16. Now when i try to run this applet on my IE under jre 1.5.* family on all the cli

  • Install on IBM Thinkpad X20

    Has anyone successfully installed Solaris 8 on IBM Thinkpad X20? Anything can been shared? I have Windows 2000 Professional on it already, and two empty partitions as well. Thanks!

  • PO rejection via workflow

    Hello Guru's, I have a senario where the PO needs to be released or rejected in Background mode via workflow. Currently I am using the task with calls the transaction ME29n, but you all know the users will not have authorization for transaction ME29n

  • Is there a known issue with motherboard resources with nf2?

    hello, i just bought an epox nf2, setup everything, install xp pro, BUT after installing all drivers, i get a punctuation mark on one of the motherboard resources in dvice manager, its the second one, because i think there are 3 mobo resources.  what

  • I like to play ahead of the beat, but...

    I prefer to not use quantization, to optimize the human feel factor. But this means that -- for a given song where it calls for playing slightly ahead of the beat -- the notes are slightly ahead of the grid. Therefore my regions do not begin exactly