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 8596897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:47:25+00:00 2026-06-12T00:47:25+00:00

I’m new to Oracle, and new to Oracle Application Express. I’m working through a

  • 0

I’m new to Oracle, and new to Oracle Application Express.

I’m working through a manual and I’m trying to create a table with 3 fields:

USER_ID: Number, Primary Key, Autonumber

USER_NAME: VARCHAR2, Unique

PASSWORD: VARCHAR2

I used the APEX SQL Workshop wizard to create the table, but when I try to do something like the following:

INSERT INTO Schema.USERS (USER_NAME,PASSWORD) VALUES ('planet','password');

…I get told that a unique constraint on the Primary Key is violated.

A trigger was automatically created by the Table Creation wizard. It looks like this:

create or replace trigger "BI_USERS" 
  before insert on "USERS"               
  for each row  
begin   
  if :NEW."USER_ID" is null then
    select "USERS_SEQ".nextval into :NEW."USER_ID" from sys.dual;
  end if;
end; 

I was under the impression this would automatically find the highest numeric value in the USER_ID field of USERS and automatically assign an incremented value to each new INSERT, but this doesn’t appear to be happening.

Can anyone suggest what I might be doing wrong?

Many thanks

pt

  • 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-12T00:47:26+00:00Added an answer on June 12, 2026 at 12:47 am

    Sequences: http://www.techonthenet.com/oracle/sequences.php

    (Quoted from linked article)
    In Oracle, you can create an autonumber field by using sequences. A
    sequence is an object in Oracle that is used to generate a number
    sequence. This can be useful when you need to create a unique number
    to act as a primary key.

    …

    This insert statement would insert a new record into the suppliers
    table. The supplier_id field would be assigned the next number from
    the supplier_seq sequence. The supplier_name field would be set to
    Kraft Foods.

    You said:

    I was under the impression this would automatically find the highest
    numeric value in the USER_ID field of USERS and automatically
    assign an incremented value to each new INSERT, but this doesn’t
    appear to be happening.

    No. A sequence will simply generate the next value based on the last value and the increment, and is not tied to your data.

    select nvl(max(user_id), 0) + 1 
      into v_next_val 
      from users 
    

    Is something that would look at your data and increment the highest USER_ID with 1.

    If right now you are getting constraint violations due to the primary key on USER_ID, this might mean you have inserted data into your users table, and this data contained values for the USER_ID column.
    For instance, say created 3 records and manually assigned a value to USER_ID without using a sequence

    insert into users (user_id, user_name) values (1, 'John');
    insert into users (user_id, user_name) values (2, 'Jerry');
    insert into users (user_id, user_name) values (3, 'Bob');
    

    When you then start using the sequence (or create it only then), the sequence will start at the specified start with value = 1.
    So doing

    insert into users (user_name) values ('planet');
    

    would generate a constraint violation because sequence.nextval would be 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

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.