Autonumber in SQL

Is there a way i can get an autonumber in SQL,
I have a databse and i want the database to have a primary key that is an autonumber, whenever a row is added it automatically enters the key in there.
I am using Access as the front end for this database.
Thanks
ashish

CREATE SEQUENCE
Purpose
Use the CREATE SEQUENCE statement to create a sequence, which is a database object from which multiple users may generate unique integers. You can use sequences to automatically generate primary key values.
When a sequence number is generated, the sequence is incremented, independent of the transaction committing or rolling back. If two users concurrently increment the same sequence, the sequence numbers each user acquires may have gaps because sequence numbers are being generated by the other user. One user can never acquire the sequence number generated by another user. Once a sequence value is generated by one user, that user can continue to access that value regardless of whether the sequence is incremented by another user.
Sequence numbers are generated independently of tables, so the same sequence can be used for one or for multiple tables. It is possible that individual sequence numbers will appear to be skipped, because they were generated and used in a transaction that ultimately rolled back. Additionally, a single user may not realize that other users are drawing from the same sequence.
Once a sequence is created, you can access its values in SQL statements with the CURRVAL pseudocolumn (which returns the current value of the sequence) or the NEXTVAL pseudocolumn (which increments the sequence and returns the new value).
See Also:
"Pseudocolumns" for more information on using the CURRVAL and NEXTVAL
"How to Use Sequence Values" for information on using sequences
ALTER SEQUENCE or DROP SEQUENCE for information on modifying or dropping a sequence
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_615a.htm#SQLRF01314
Joel P�rez

Similar Messages

  • Autonumber in oracle

    how can i create autonumber using sql???
    i wan to create a table TB1 and have a tableID which is autonumber....strart with 100001,100002,100003.....the number is auto increment when i insert a new record...

    You can use Sequence ( either inside a trigger or directly from your code) to auto generate id every time you insert a record in database
    See details here
    http://asktom.oracle.com/pls/ask/f?p=4950:8:5997758950318386518::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6265048691988,
    You should also see this one to decide which way to use :
    http://asktom.oracle.com/pls/ask/f?p=4950:8:5997758950318386518::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6575961912937,
    Chandar

  • Moving Access table with an autonumber key to SQL Server table with an identity key

    I have an SSIS package that is moving data from an Access 2010 database to a SQL Server 2008 R2 database.  Two of the tables that I am migrating have identity keys in the SQL Server tables and I need to be able to move the autonumber keys to the SQL
    Server tables.  I am executing a SQL Script to set the IDENTITY_INSERT ON before I execute the Data Flow task moving the data and then execute a SQL Script to set the IDENTITY_INSERT OFF after executing the Data Flow task.
    It is failing with an error that says:
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80040E21  Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was
    done.".
    Error: 0xC020901C at PGAccountContractDetail, PGAccountContractDetail [208]: There was an error with input column "ID" (246) on input "OLE DB Destination Input" (221). The column status returned was: "User does not have permission to
    write to this column.".
    Error: 0xC0209029 at PGAccountContractDetail, PGAccountContractDetail [208]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "input "OLE DB Destination Input" (221)" failed because error code 0xC020907C occurred, and the
    error row disposition on "input "OLE DB Destination Input" (221)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information
    about the failure.
    Error: 0xC0047022 at PGAccountContractDetail, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "PGAccountContractDetail" (208) failed with error code 0xC0209029 while processing input "OLE DB
    Destination Input" (221). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted
    before this with more information about the failure.
    Any ideas on what is causing this error?  I am thinking it is the identity key in SQL Server that is not allowing the update.  But, I do not understand why if I set IDENTITY_INSERT ON.  
    Thanks in advance for any help/guidance provided.

    I suspect it is the security as specified in the message. E.g .your DBA set the ID columns so no user can override values in it.
    And I suggest you 1st put the data into a staging table, then push it to the destination, this does not resolve the issue, but ensures better processing.
    Arthur
    MyBlog
    Twitter

  • Create Autonumber GUID using SQL Statment

    Hi Everyone,
    I have an Access 2013 database. In it, I use SQL statements heavily in VBA to process transactions, modify system date, process updates etc. I am at a point where I would like to create a table with an SQL Statement. Sounds easy. Do it all the time. But
    I want the ID field and PK to be an AutoNumber ReplicationID (or GUID).
    It's easy enough to create an AutoNumber using the AUTOINCREMENT datatype in SQL and it's easy enough to create a ReplicationID field using the GUID data type. BUT ... I can't create an AutoNumber Replication ID field.
    I have a function called GetGUID(). There are examples that I have found where using a simple function like that as the default value for the field should work but access keeps telling me that the function is not found or not valid.
    The SQL statement that creates an AutoNumber (Long) looks like this:
    CREATE TABLE myTable
    ID AUTOINCREMENT PRIMARY KEY UNIQUE,
    Field1 VARCHAR(255) NOT NULL,
    Field2 GUID NOT NULL,
    SomeDate DATE,
    SomeTime TIME,
    Field3 VARCHAR(255),
    If anyone can help make this script create an AutoNumber GUID, I would appreciate it.
    P.S. I can create this using DAO Table Defs, but that doesn't fit with the DQL Statement based update process that I need it to.
    Cheers
    Stephen, RedGalaxy Darwin, Australia

    You cannot use your own function GetGUID() in the default property of a field in a table. Only built-in functions are allowed, and GenGUID() is the built-in Access function to generate GUIDs.
    The reason why you are gettting the #Error is explained in
    Alex Dybenko's Access Blog
    Unfortunately, it is not possible to modify the Attributes property after the table has been created. But normally, such a GUID field is hidden from the user. If it doesn't bother you, just leave it as is. Otherwise, you will have to create an exact copy
    of the table using DAO (and possibly ADOX) methods.
    Matthias Kläy, Kläy Computing AG

  • SQL Server - Autonumber identity

    Hi all,
    does toplink support the sql server autonumber identity?
    actually i try to add a new record to a table where the primarykey is an autonumber (incremented automatically by 1 with every insert) and i keep get a toplink exception saying that a null primary key value can't be inserted
    thanks

    I suspect it is the security as specified in the message. E.g .your DBA set the ID columns so no user can override values in it.
    And I suggest you 1st put the data into a staging table, then push it to the destination, this does not resolve the issue, but ensures better processing.
    Arthur
    MyBlog
    Twitter

  • SQL and autoNumber problem!!! Pls help!

    Hi everyone!!
    I am very new with using SQL language to connect to a database.
    In my database, i have a certain table called 'Tourists' and the primary key of this table is TouristID. The data type of the primary key is an autoNumber.
    When i use SQL statement like
    String strDelete = "DELETE FROM Tourists WHERE TouristID="+touristID;
    With this I get an run time error :
    ****Data type mismatch in criteria expression.****
    This is because i save the variable as an Integer..
    IS there a way to save me ??? Plss helpp needed! :)
    Thanx

    Thnks just one question!!
    Is the primary key variable in Access an auto number!
    What i mean is that is the varibale type in database an auto number!
    That is my problem!! The tourist ID is an autonumber in Access!
    Below is the erorr!!
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2525)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:252)
         at TouristRegistrationGUI.deleteRecord(TouristRegistrationGUI.java:500)
         at TouristRegistrationGUI.buttonClicked(TouristRegistrationGUI.java:217)
         at BreezySwing.GBDialogButtonListener.actionPerformed(GBDialog.java:459)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
         at java.awt.Component.processMouseEvent(Component.java:5021)
         at java.awt.Component.processEvent(Component.java:4818)
         at java.awt.Container.processEvent(Container.java:1380)
         at java.awt.Component.dispatchEventImpl(Component.java:3526)
         at java.awt.Container.dispatchEventImpl(Container.java:1437)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
         at java.awt.Container.dispatchEventImpl(Container.java:1423)
         at java.awt.Window.dispatchEventImpl(Window.java:1566)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:134)
         at java.awt.Dialog.show(Dialog.java:524)
         at ExoticToursGUI.buttonClicked(ExoticToursGUI.java:186)
         at BreezySwing.GBFrameButtonListener.actionPerformed(GBFrame.java:518)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
         at java.awt.Component.processMouseEvent(Component.java:5021)
         at java.awt.Component.processEvent(Component.java:4818)
         at java.awt.Container.processEvent(Container.java:1380)
         at java.awt.Component.dispatchEventImpl(Component.java:3526)
         at java.awt.Container.dispatchEventImpl(Container.java:1437)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
         at java.awt.Container.dispatchEventImpl(Container.java:1423)
         at java.awt.Window.dispatchEventImpl(Window.java:1566)
         at java.awt.Component.dispatchEvent(Component.java:3367)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

  • Autonumber? or sql? or how?

    I have a child (detail) block in tubular form. I need to have a field that will number each row/results after the master is queried. ie.
    MASTER = company
    details= employees
    details block looks like this:
    NUMBER | NAME | LAST_NAME |ADDRESS
    1
    2
    3
    4
    so I need that for every new record on the detail block, the next number is generated. So if a new employee gets inserted for this compay, the field "Number" created will be 5. by the same token if a company has 2 records, then the next time someone gets inserted they receive the value of 3 and so on.
    can you guys please help me with this? I dont even know where to start.
    thanks!

    The above procedure (seqno_prc) have some bugs, for example if the user deletes
    a row in the detail block, the sequence of the rows above and rows down this deleted row will not change, it should recalculated.
    It's better to generate squence of the detail rows just before saving the form.
    For me i use when-button-pressed for a save button then i navigate through the detail block , increment the counter and fetch it's value on the item that have the row number, then commit the form .
    and everythig is working fine.

  • Java and MS-Access: Login Authentication trough SQL

    Hi all,
    I am currently new to the world of java and would like to ask something for a school project.
    We have an MS-Access database setup which we want to use as an login-database.
    We can select from the tables in the database using a standard SQL query, and print out the output, but we do not know how to combine the java-string "UserID" and "Corrpass" field to compare them with the database to check if the entered login is correct.
    I know this question is a little bit on the SQL side, but could you please help me? The code for printing out Usernames was founfdon the bottom of this webpage:
    http://www.ster.be/java/java6.html
    Our Microsoft Access Database Layout:
    MS-Access Database
    Table: Users
    | UserID -AutoNumber : UserID (Login code)
    | Corrpass -text :The Correct Password for the above UserID
    | UserVoornaam -text : First name
    | UserAchternaam -text : Surname
    All help/welcome/advise/flaming posts are welcome.

    Hi all,
    I am currently new to the world of java and would like to ask something for a school project.
    We have an MS-Access database setup which we want to use as an login-database.
    We can select from the tables in the database using a standard SQL query, and print out the output, but we do not know how to combine the java-string "UserID" and "Corrpass" field to compare them with the database to check if the entered login is correct.
    I know this question is a little bit on the SQL side, but could you please help me? The code for printing out Usernames was founfdon the bottom of this webpage:
    http://www.ster.be/java/java6.html
    Our Microsoft Access Database Layout:
    MS-Access Database
    Table: Users
    | UserID -AutoNumber : UserID (Login code)
    | Corrpass -text :The Correct Password for the above UserID
    | UserVoornaam -text : First name
    | UserAchternaam -text : Surname
    All help/welcome/advise/flaming posts are welcome.

  • How to get an sql query result to a textbox?

    i am working with jdk1.4 and office 2003.
    i need to run the following SQL Query: "SELECT max(BookId) as BookId FROM Books" where BookId is an autonumeric generated number obtained from the field autonumber in access 2003 database.
    now, the result of this must be placed in a textbox.
    does anyone knows how to do this?
    I ve tried this but nothing happens and niether any error comes
    st = con.createStatement ();     //Creating Statement Object.
    long bookNo;          //Use for Comparing the Book's Id.
    try {     //SELECT Query to Retrieved the Record.
    String q = "SELECT max(BookId) as BookId FROM Books";
    ResultSet rs = st.executeQuery (q);     //Executing the Query.
    bookNo = rs.getLong ("BookId");          //Storing the Record.
    bookNo =(bookNo+1);
    txtBookId.setText (""+bookNo);
    catch (SQLException sqlex) { }
    does anyone knows how to do this?????plz help me out.
    Thanks
    Aanchal

    Hi Aanchal,
    If an SQL error occurs now, you cannot see it in your code. You should do something with the exception you catch, e.g. printing it: sqlex.printStackTrace(), so that you can see if something goes wrong.
    For your number, you should move the cursor in the resultset to the first row - either by: calling first( ) or next ( ), then you can retrieve your booknumber.
    Best Regards,
    Martijn

  • Create Trigger (PK from Sequence) in SQL Developer 1.5.1

    Hi all
    I'm new to Oracle and am trying to create the equivalent of an autonumber field on a table using the Create Trigger (PK from Sequence) option (by right clicking on a table in SQL Developer).
    I've set up a sequence called REQUESTID and when using the above option it generates the following SQL:
    begin
    execute immediate 'create or replace trigger AutoNumber '||
         ' before insert on "REQUEST" '||
         ' for each row '||
         'begin '||
         ' if inserting then '||
         ' if :NEW."REQUESTID" is null then '||
         ' select REQUESTID.nextval into :NEW."REQUESTID" from dual; '||
         ' end if; '||
         ' end if; '||
         'end;';
         end;
    When I click Apply I get an ORA-00942 (table or view does not exist). Am I doing something daft here?

    Never mind - sorted it - I created the table under a different Schema to the System login being used in SQL Developer and so didn't have the permissions to create the trigger on the table.

  • Autonumber id numbering reset

    How do I reset my keyfield ID which is an autonumber field? I have been running a module to check out my sql logic and now I need to change the ID number back to zero before I do the actual processing of my data.

    869848 wrote:
    How do I reset my keyfield ID which is an autonumber field? I have been running a module to check out my sql logic and now I need to change the ID number back to zero before I do the actual processing of my data.Oracle does NOT have autonumber field.
    Are you actually using MYSQL?

  • Java Dictionary Project + create autonumber for KEY field?

    Hi there,
    I would like to create a Java Dictionary project that has a table with an AUTONUMBER as the key field.
    I know exactly how to do this in SQL Server using the IDENTITY field but cannot see an option when using the Java Dictionary project?
    Any ideas?
    Thanks for the help
    Lynton

    Has there been an update to this recently?  I am in need of exactly the same information.  The FAQ lists this:
    <i>Can I deploy a Java Dictionary table along with the table content?
    Yes. You can deliver the Java Dictionary table along the table content. There are two possibilities:
    Export from a reference database
    Specification of the table entries in an XML file (since SP5)
    Note that there is no modification support for table entries that are delivered in this way. Therefore, you can deliver table entries with program character or for examples, but not for templates or customizing data.</i>
    Now, I may be reading the note incorrectly, but it makes it sound like if you do populate a table with a XML file, the records cannot be modified thereafter.  Is this true?
    I'd also like to know how to develop the XML and where to put it, etc.  I've had no luck searching for this information.
    Thanks!

  • SQL: Delete woes part...3?

    Thanks to lionstone, I think I'm getting the hang of complex
    DELETE queries.
    I'm stuck on this one though:
    DELETE faqvars
    FROM
    [SQLCRTPUB\COURTSPUBLIC].DBCourtsPub.CourtsPub.WeFAQsVariations
    faqvars
    WHERE EXISTS
    (SELECT *
    FROM
    [SQLCRTPUB\COURTSPUBLIC].DBCourtsPub.CourtsPub.WeFAQs faqs
    INNER JOIN
    [SQLCRTPUB\COURTSPUBLIC].DBCourtsPub.CourtsPub.We_about_categories
    cats ON faqs.categoryID = cats.categoryID
    WHERE (faqvars.collectionID =
    faqs.collectionID) AND (faqs.categoryID = 9 OR
    cats.categoryParentID =
    9))
    That gives me this error:
    SQL Server Enterprise Manager
    [Microsoft][ODBC SQL Server Driver][SQL Server][OLE/DB
    provider returned
    message: Multiple-step OLE DB operation generated errors.
    Check each OLE DB
    status value, if available. No work was done.]
    This seems to be a bit of a random error. So, two questions:
    1) anyone see
    anything particularily wrong with my syntax above and 2) how
    do I go about
    debugging a 'multiple-step OLE DB' operation in SQL Manager?
    -Darrel

    "darrel" <[email protected]> wrote in message
    news:ete7p3$bab$[email protected]..
    > Is the 'fix' for this to just add a new column to the
    public facing tables
    > with a PK? Better method?
    >
    > -Darrel
    You're confusing a primary key with an identity column.
    Primary key is not the same as identity or autonumber
    Primary key <> identity/autonumber
    Primary key != identity/autonumber
    Sorry, pet peeve. :)
    A primary key can be anything at all, or even span more than
    one column.
    Its only requirement is that it identifies a row uniquely. An
    identity is
    an auto-incrementing integer column that takes a seed (first
    value) and
    increment (the amount added to the last value for the next
    value). A
    primary key constraint does not set any values; that's a
    property shared by
    the IDENTITY property and DEFAULT constraints.
    Are you noticing a performance problem on your databases? A
    primary key
    creates a clustered index for you; without a clustered index,
    your table is
    just a heap. You can certainly create a clustered index on
    columns other
    than the key columns, but you need to have one somewhere in
    the table.
    On the public database, add the primary key constraint. Just
    don't make the
    column an identity column.
    So for the internal DB, you'd have:
    CategoryID INT NOT NULL IDENTITY(1,1)
    And on the public DB you'd have:
    CategoryID INT NOT NULL
    On *both* DB's you'll have:
    PRIMARY KEY(CategoryID)
    To add the key to an existing table, run the following
    statement (you can
    add a key constraint to an existing column with no problems,
    so long as the
    data in that column is already unique):
    ALTER TABLE <table name>
    ADD PRIMARY KEY(<column name(s)>)
    GO
    If you've got a clustered index elsewhere in the table, you
    may have to add
    the NONCLUSTERED keyword. If you don't know, then LEAVE IT
    OFF - let the DB
    throw an error first. The clustered index is very important,
    and you should
    always have indexes on columns that are used in joins.

  • SQL- Obtaining primary key in newly inserted data

    Anyone know of an easy way to obtain a primary autonumber key from a newly inserted record ??
    Martin

    "Martin Eder" wrote:
    >This is a multi-part message in MIME format.>>------=_NextPart_000_0010_01C07707.14E4F6C0>Content-Type:
    text/plain;> charset="iso-8859-1">Content-Transfer-Encoding: quoted-printable>>Anyone
    know of an easy way to obtain a primary autonumber key from a =>newly inserted
    record ??>>Martin>>------=_NextPart_000_0010_01C07707.14E4F6C0>Content-Type:
    text/html;> charset="iso-8859-1">Content-Transfer-Encoding: quoted-printable>>
    HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">>>content=3D"text/html; =>charset=3Diso-8859-1">>name=3DGENERATOR>>>>>
    face=3DArial size=3D2>Anyon
    e know of an easy way to obtain a =>primary=20>autonumber
    key from a newly inserted record ??>
    size=3D2> >Martin>>------=_NextPart_000_0010_01C07707.14E4F6C0-->
    Yes, for MS SQL7 modify the EasySQL vi to execute the SQL command 'SELECT
    @@IDENTITY' the query results will contain the identity of the inserted row.

  • SQL Insert and Select statements on same page

    Newbie here.
    Is it possible to insert data from a form to a database and then get data from the database using "select" from the same page.
    I have a form that submits the authors details to an Access database but I need to get the AuthorID (which is an autonumber in the table) to show on the same page.
    <%@ page language="java" contentType="text/html" import="java.sql.*" %>
    <html>
    <head>
    <title>Confirm Details Submission</title>
    </head>
    </body>
    <%
    String title = request.getParameter("title");
    String surname = request.getParameter("surname");
    surname = surname.replaceAll("'", "''");
    String forename = request.getParameter("forename");
    forename = forename.replaceAll("'", "''");
    String address = request.getParameter("address");
    address = address.replaceAll("'", "''");
    String address2 = request.getParameter("address2");
    address2 = address2.replaceAll("'", "''");
    String town = request.getParameter("town");
    town = town.replaceAll("'", "''");
    String postcode = request.getParameter("postcode");
    String email = request.getParameter("email");
    email = email.replaceAll("'", "''");
    String dob = request.getParameter("dob");
    String telephone = request.getParameter("telephone");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
    Statement Stmt = Conn.createStatement();
    String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
    //Stmt.executeUpdate(Query) is where the records are inserted.
    int SQLStatus = Stmt.executeUpdate(Query);
         if(SQLStatus != 0)
    %>
    Thank you. Your Author ID number is ??
    <%
    else
    %>
    Error - Your details have not been submitted</font></h4>
    <br>
    Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
    <%
    Stmt.close(); Conn.close();
    %>
    </body>
    </html>

    Hi,
    You could execute queries as many times as you want using the same connection.
    For ex;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection Conn = DriverManager.getConnection("jdbc:odbc:Novbase","","");
    Statement Stmt = Conn.createStatement();
    String Query = ("INSERT INTO Author (Title, Surname, Forename, Address, Address2, Town, Postcode, EMail, DOB, TelNo) VALUES ('" + title + "', '" + surname + "', '" + forename + "', '" + address + "', '" + address2 + "', '" + town + "', '" + postcode + "', '" + email + "', '" + dob + "', '" + telephone +"')");
    //Stmt.executeUpdate(Query) is where the records are inserted.
    int SQLStatus = Stmt.executeUpdate(Query);
    if(SQLStatus != 0)
    Query = "SELECT Forname FROM Author;";
    ResultSet name = stmt.executeQuery(Query);
    //Now name will have all the Forname fields in the database. You could retrieve that using the get methods.
    %>
    Thank you. Your Author ID number is ??
    <%
    else
    %>
    Error - Your details have not been submitted</font></h4>
    <br>
    Please click back on your browser and try again. If you experience further difficulties please go to our <a href ="help.html">help</a> pages.<br>
    <%
    Stmt.close(); Conn.close();
    %>
    I hope that can help you.
    Rajesh

Maybe you are looking for