Oracle Apex - Sequence Assignment - Resolution of the ORA-01400

Card Puncher Data Processing


When you create an application from a table with a primary key, you expect that Apex has an pre-build option to create and manage the sequence of this column.

But it's not the case. Then when you want insert a new row in your table, you will have this error :

ORA-01400: cannot insert NULL into ("QS_APEX"."DEMO_CUSTOMER"."CUSTOMER_ID")
Error 	Unable to process row of table DEMO_CUSTOMER.

How to resolve this error ?

How to

You have to create manually the link between the primary key and the sequence with a trigger as you can see below in the admin schema that is delivered with the sample application.

Go to the Workshop, create a sequence and add a trigger as this one below :

Apex Sequence Assignement

Code of the Trigger “INSERT_DEMO_CUST” :

create or replace TRIGGER  "INSERT_DEMO_CUST" 
BEFORE INSERT ON demo_customers
  cust_id number;
  SELECT demo_cust_seq.nextval
    INTO cust_id
    FROM dual;
  :new.CUSTOMER_ID := cust_id;

Discover More
Card Puncher Data Processing
Oracle Apex

Oracle Application Express (Oracle APEX) is a rapid web application development tool for the Oracle database. Application : OBE...

Share this page:
Follow us:
Task Runner