We have a table with column name 'Name' that has been set to NOT NULL.
However, when we recently had an issue due to NULL values in this table.
We have checked the script that populates the table and test various scenarios by trying to insert a null value manually and this fails ( as would be expected)
- Check table does not accept null values:
DESC LRF_PRT_REQUESTOR
Name Null Type
----------------- -------- -----------------
PRT_REQSTR_ID NOT NULL NUMBER(9)
FACILITY_ID NOT NULL NUMBER(9)
NAME NOT NULL VARCHAR2(20 CHAR)
PRT_REQSTR_DESC NOT NULL VARCHAR2(40 CHAR)
PRIORITY NOT NULL NUMBER(9)
CREATED_DTTM NOT NULL TIMESTAMP(6)
LAST_UPDATED_DTTM TIMESTAMP(6)
- Try to insert a null quoted value
Error starting at line : 5 in command -
INSERT INTO LRF_PRT_REQUESTOR
SELECT LRF_PRT_REQSTR_ID_SEQ.NEXTVAL, -- PRT_REQSTR_ID
1, -- FACILITY_ID
'', -- NAME
'', -- PRT_REQST_DESC
1, -- PRIORITY
SYSDATE, SYSDATE
FROM DUAL
Error report -
SQL Error: ORA-01400: cannot insert NULL into ("WM14DEV1A"."LRF_PRT_REQUESTOR"."NAME")
- 00000 - "cannot insert NULL into (%s)"
*Cause:
*Action:
- Try to insert specific null into table .
Error starting at line : 5 in command -
INSERT INTO LRF_PRT_REQUESTOR
SELECT LRF_PRT_REQSTR_ID_SEQ.NEXTVAL, -- PRT_REQSTR_ID
1, -- FACILITY_ID
null, -- NAME
null, -- PRT_REQST_DESC
1, -- PRIORITY
SYSDATE, SYSDATE
FROM DUAL
Error report -
SQL Error: ORA-01400: cannot insert NULL into ("WM14DEV1A"."LRF_PRT_REQUESTOR"."NAME")
- 00000 - "cannot insert NULL into (%s)"
*Cause:
*Action:
- Insert V_name variable with null values ( as per script).
Error starting at line : 16 in command -
declare
v_name varchar2(10);
begin
INSERT INTO LRF_PRT_REQUESTOR
SELECT LRF_PRT_REQSTR_ID_SEQ.NEXTVAL, -- PRT_REQSTR_ID
1, -- FACILITY_ID
v_name, -- NAME
v_name, -- PRT_REQST_DESC
1, -- PRIORITY
SYSDATE, SYSDATE
FROM DUAL;
end;
Error report -
ORA-01400: cannot insert NULL into ("WM14DEV1A"."LRF_PRT_REQUESTOR"."NAME")
ORA-06512: at line 5
- 00000 - "cannot insert NULL into (%s)"
*Cause:
*Action:
The only anomaly we see if when we write a select statement in SQL Developer the word 'name' is highlighted in blue to suggest that it is a reserved word.
Is name a reserved word in sql developer and if so, is it referring to a function that exists possibly?
We are struggling to determine how NULL values are being inserted.