ORA-00908
ORA-00908: упущено ключевое слово NULL
Причина:
В операторе CREATE TABLE или ALTERB TABLE, NOT вводится для указания, что не нулевые (not null) величины допускаются в колонке, но ключевое слово NULL пропущено.
Действие:
Если вы хотите предъявлять требование к величинам, измените ключевое слово NOT на NOT NULL, затем перевыполните снова оператор.
I’m trying to do an update to a table that contains records pertaining to people under Oracle 11g. I have a column that contains IDs, some of which contain hyphens. The table has a constraint on this ID so two different people can’t have the same ID. My goal is to remove the hyphens, while avoiding any constraint violations when I do an update. So I tried this query to detect records that would violate the constraint:
SELECT count(*) FROM people
WHERE externalid LIKE '%-%' AND
replace(externalid, '-') IS IN (SELECT externalid FROM people);
This then fails with an ORA-00908: missing NULL keyword. I know this is due to that last line, but I don’t know how else to structure that part of the query to detect the records that have the non-hyphenated ID already in use. How can I detect these records that would violate the constraint?
asked Feb 28, 2013 at 19:16
The IS
keyword is used as in something IS NULL
, not with the IN
keyword. That’s why the database thinks that there is a NULL missing. Just remove the IS
:
SELECT count(*) FROM people
WHERE externalid LIKE '%-%' AND
replace(externalid, '-') IN (SELECT externalid FROM people);
answered Feb 28, 2013 at 19:22
GuffaGuffa
685k108 gold badges735 silver badges1002 bronze badges
1
I’m not sure if this will work in oracle but worth a try:
SELECT * FROM people p1
Inner Join people p2 on replace(p1.externalid, '-') = p2.externalid
and p1.externalid < p2.externalid --prevents duplicate matches
Where p1.externalid LIKE '%-%'
answered Feb 28, 2013 at 19:22
AaronLSAaronLS
37.1k20 gold badges143 silver badges202 bronze badges
ORA-00908: missing NULL keyword
Oracle PL/SQL error message: ORA-00908: missing NULL keyword.
Cause:
Either of the following: In a CREATE TABLE or ALTER TABLE statement, NOT was entered to specify that no null values are allowed in that column, but the keyword NULL was omitted. In the IS [NOT] NULL logical operator, the keyword NULL was not found.
Solution:
Check the syntax and correct.
Example:
SELECT s.first_name, s.LAST_NAME FROM students s WHERE s.ADDRESS IS NOT;
Output:
ORA-00908: missing NULL keyword
Correct:
SELECT s.first_name, s.LAST_NAME FROM students s WHERE s.ADDRESS IS NOT NULL;
Learn the cause and how to resolve the ORA-00908 error message in Oracle.
Description
When you encounter an ORA-00908 error, the following error message will appear:
- ORA-00908: missing NULL keyword
Cause
You tried to execute a SQL statement, but you missed entering the NULL keyword.
Resolution
The option(s) to resolve this Oracle error are:
Option #1
This error can occur if you try to execute a SQL statement using the IS NULL condition or IS NOT NULL condition, but miss entering the NULL keyword.
For example, if you tried executing the following statement:
SELECT * FROM suppliers WHERE supplier_name IS NOT;
You would receive the following error message:
You could correct this error, by modifying the statement as follows:
SELECT * FROM suppliers WHERE supplier_name IS NOT NULL;
Solution 1
The IS
keyword is used as in something IS NULL
, not with the IN
keyword. That’s why the database thinks that there is a NULL missing. Just remove the IS
:
SELECT count(*) FROM people
WHERE externalid LIKE '%-%' AND
replace(externalid, '-') IN (SELECT externalid FROM people);
Solution 2
I’m not sure if this will work in oracle but worth a try:
SELECT * FROM people p1
Inner Join people p2 on replace(p1.externalid, '-') = p2.externalid
and p1.externalid < p2.externalid --prevents duplicate matches
Where p1.externalid LIKE '%-%'
Comments
-
I’m trying to do an update to a table that contains records pertaining to people under Oracle 11g. I have a column that contains IDs, some of which contain hyphens. The table has a constraint on this ID so two different people can’t have the same ID. My goal is to remove the hyphens, while avoiding any constraint violations when I do an update. So I tried this query to detect records that would violate the constraint:
SELECT count(*) FROM people WHERE externalid LIKE '%-%' AND replace(externalid, '-') IS IN (SELECT externalid FROM people);
This then fails with an ORA-00908: missing NULL keyword. I know this is due to that last line, but I don’t know how else to structure that part of the query to detect the records that have the non-hyphenated ID already in use. How can I detect these records that would violate the constraint?
-
Oh god, you’re right. I totally had a brainfart there.