January 4th, 2012, 09:17 AM
Join Date: Jan 2012
Time spent in forums: 45 m 23 sec
Reputation Power: 0
ORA-01400: cannot insert NULL
I am working on a project, the insert statement is not functioning properly and I cannot find the error The error is in the insert statement for CustOrder. The error states that NULL cannot be inserted into CustOrder.CustID. I have declared CustID and its reference. I have looked over the code several times and I cannot find the problem.
If it makes a difference I am using APEX. The company has not database or program to work with a database so I am building everything from scratch.
Any advice is greatly appreciated. Thanks in advance!
l_CustID number := :P11_CustID;
if :P11_CUSTOMER_OPTIONS = 'NEW' then
l_CustID := :P18_CustID;
-- Fetch values that need to be inserted into the Order Header
select CustOrder_seq.nextval into l_CustOrderID from dual;
-- Insert a row into the Order Header table
insert into CustOrder values(l_CustOrderID, sysdate, l_CustID, NULL, NULL);
-- Loop through the ORDER collection and insert rows into the Order Line Item table
for x in (select c001, c003, sum(c004) c004 from apex_collections
where collection_name = 'ORDER' group by c001, c003)
insert into OrderLine values
(NULL, l_CustOrderID, x.c001, to_number(x.c004), to_number(x.c003));
-- Truncate the collection after the order has been placed
apex_collection.truncate_collection(p_collection_n ame => 'ORDER');
-- Set the item P14_ORDER_ID to the order which was just placed
:P14_CustOrderID := l_CustOrderID;