Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
ORA-61800 is new with the SQL BOOLEAN type in Oracle 23ai. When a string meets a BOOLEAN (inserted into a BOOLEAN column, compared with one, or passed to TO_BOOLEAN), Oracle converts it. Strings such as 'Y', 'N', 'yes' and 'off' convert; anything else stops the statement and the message shows the bad value.
It shows up most when old Y/N flag columns are moved to BOOLEAN. 3 cases reproduced on Oracle 23ai (26ai Free).
01Copying a VARCHAR2 Y/N flag into a BOOLEAN column when one row has another value
The old use_yn column has Y, N and one 'X'. INSERT ... SELECT id, use_yn converts each value, and the whole INSERT fails on X.
Setup
CREATE TABLE items_old (id NUMBER PRIMARY KEY, use_yn VARCHAR2(1));
INSERT INTO items_old VALUES (1, 'Y');
INSERT INTO items_old VALUES (2, 'N');
INSERT INTO items_old VALUES (3, 'X');
COMMIT;
CREATE TABLE items (id NUMBER PRIMARY KEY, in_use BOOLEAN);Table created.
1 row created.
1 row created.
1 row created.
Commit complete.
Table created.INSERT INTO items (id, in_use) SELECT id, use_yn FROM items_old;INSERT INTO items (id, in_use) SELECT id, use_yn FROM items_old
*
ERROR at line 1:
ORA-61800: invalid boolean literal: X
Help: https://docs.oracle.com/error-help/db/ora-61800/SELECT id, use_yn FROM items_old WHERE VALIDATE_CONVERSION(use_yn AS BOOLEAN) = 0; ID U
---------- -
3 X
1 row selected.Find the rows that will fail with VALIDATE_CONVERSION(use_yn AS BOOLEAN) = 0 (here only id 3, X). Then map the values yourself: CASE use_yn WHEN 'Y' THEN TRUE WHEN 'N' THEN FALSE END. 3 rows are inserted; X becomes NULL. Decide what X should mean before you run it in production.
INSERT INTO items (id, in_use)
SELECT id, CASE use_yn WHEN 'Y' THEN TRUE WHEN 'N' THEN FALSE END FROM items_old;
SELECT id, in_use FROM items ORDER BY id;3 rows created.
ID IN_USE
---------- -----------
1 TRUE
2 FALSE
3
3 rows selected.02Comparing a BOOLEAN column with a status code string
active is BOOLEAN, but the query still uses the old code style active = 'A'. 'A' is not a boolean literal.
Setup
CREATE TABLE users (id NUMBER PRIMARY KEY, name VARCHAR2(20), active BOOLEAN);
INSERT INTO users VALUES (1, 'kim', TRUE);
INSERT INTO users VALUES (2, 'lee', FALSE);
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.SELECT id, name FROM users WHERE active = 'A';SELECT id, name FROM users WHERE active = 'A'
*
ERROR at line 1:
ORA-61800: invalid boolean literal: A
Help: https://docs.oracle.com/error-help/db/ora-61800/SELECT column_name, data_type FROM user_tab_columns WHERE table_name = 'USERS' ORDER BY column_id;COLUMN_NAME DATA_TYPE
------------------------------ --------------------------------------------------------------------------------------------------------------------------------
ID NUMBER
NAME VARCHAR2
ACTIVE BOOLEAN
3 rows selected.USER_TAB_COLUMNS confirms ACTIVE is BOOLEAN. Compare with TRUE/FALSE: WHERE active = TRUE, or simply WHERE active. Both return kim.
SELECT id, name FROM users WHERE active = TRUE;
SELECT id, name FROM users WHERE active; ID NAME
---------- ------------------------------
1 kim
1 row selected.
ID NAME
---------- ------------------------------
1 kim
1 row selected.03TO_BOOLEAN on user-entered or imported text
Values 'yes' and 'off' convert, but 'enabled' does not. The query fails on that row.
Setup
CREATE TABLE settings_stage (k VARCHAR2(20), v VARCHAR2(20));
INSERT INTO settings_stage VALUES ('mail', 'yes');
INSERT INTO settings_stage VALUES ('sms', 'off');
INSERT INTO settings_stage VALUES ('push', 'enabled');
COMMIT;Table created.
1 row created.
1 row created.
1 row created.
Commit complete.SELECT k, TO_BOOLEAN(v) AS on_off FROM settings_stage;ERROR:
ORA-61800: invalid boolean literal: enabled
Help: https://docs.oracle.com/error-help/db/ora-61800/
no rows selectedSELECT k, v, VALIDATE_CONVERSION(v AS BOOLEAN) AS ok FROM settings_stage ORDER BY k;K V OK
-------------------- -------------------- ----------
mail yes 1
push enabled 0
sms off 1
3 rows selected.VALIDATE_CONVERSION(v AS BOOLEAN) returns 0 only for push / enabled. TO_BOOLEAN(v DEFAULT NULL ON CONVERSION ERROR) returns NULL instead of failing: mail yes → TRUE, sms off → FALSE, push enabled → NULL.
SELECT k, v, TO_BOOLEAN(v DEFAULT NULL ON CONVERSION ERROR) AS on_off FROM settings_stage ORDER BY k;K V ON_OFF
-------------------- -------------------- -----------
mail yes TRUE
push enabled
sms off FALSE
3 rows selected.FAQ
What does ORA-61800 invalid boolean literal mean?
A string was converted to the BOOLEAN type and Oracle could not read it as TRUE or FALSE. The value after the colon is the one that failed.
How do I find rows that cannot be converted to BOOLEAN?
SELECT ... WHERE VALIDATE_CONVERSION(col AS BOOLEAN) = 0; lists them before you migrate.
How do I convert to BOOLEAN without an error?
Use TO_BOOLEAN(col DEFAULT NULL ON CONVERSION ERROR), or map the values explicitly with CASE.
How do I filter a BOOLEAN column in Oracle 23ai?
WHERE active = TRUE or just WHERE active. Do not compare it with code strings like 'A'.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0