Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:58:38+00:00 2026-06-13T03:58:38+00:00

I want to insert new values to an Oracle table. The table is quite

  • 0

I want to insert new values to an Oracle table. The table is quite large and the ID codes are stored as numbers. I’d like to write insert statements that can add my new information and assign an ID automatically which isn’t already taken.

For example:

insert into example_table values
(
(select max(person_id)+1 from example_table),
99, 'example name', 'example type');

But this code above obviously wouldn’t work, because I am specifying an ID (99). If I set 99 to null in the above code snippet, will it then work? Not sure how to format.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:58:38+00:00Added an answer on June 13, 2026 at 3:58 am

    you can do this by defining a sequence and trigger on the database table.
    The sequence will simply vend id’s in sequential order. The trigger will fire when the row is inserted and ask the sequence for the next available id , which it will then put into the table for you.. This way, passing NULL will work ok..

    CREATE SEQUENCE YOUR_SCHEMA_NAME.IDSEQ
      START WITH 9988
      MAXVALUE 999999999999999999999999999
      MINVALUE 1
      NOCYCLE
      NOCACHE
      NOORDER;
    
    CREATE OR REPLACE TRIGGER YOUR_SCHEMA_NAME.YOUR_TABLE_NAME_bir
    BEFORE INSERT
    ON YOUR_SCHEMA_NAME.YOUR_TABLE_NAME REFERENCING NEW AS NEW
    FOR EACH ROW
    
    BEGIN
    
      -- Custom code to: generate primary key from idseq if no id is passed
    
      IF :NEW.id IS NULL THEN
        :NEW.id := idseq.NEXTVAL;
      END IF;
    
    EXCEPTION
      WHEN OTHERS THEN
        raise_application_error(-20570, 'System error: ' || SQLCODE || ':' || SQLERRM, TRUE);
    END;
    /
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert row for each day to add new values, and I
so the problem is, that i want to insert a new row after another
I am using the html table. I want to insert a new row to
I want to insert tags in new Place. giving that tags is in different
I have a list of values I want to insert into a table via
I want insert in the row from database, array of values as that each
I currently have a stored procedure in which I want to insert new rows
EntityManager.merge() can insert new objects and update existing ones. Why would one want to
I'm new to Java. I want to create Java Array and insert data into
I want to insert a record into a MySQL database table from a formulaire.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.