Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Non-unicode VARCHAR2 flags mapping to boolean

user-didq2Jun 12 2023

Hi - we represent flags in our Oracle database as VARCHAR2(1) - that is, non-unicode - with ‘Y’/'N' values.

I have mapped these to .Net using .HasConversion(new BoolToStringConverter("N", "Y")) on the entity configuration.

This works fine when doing simple queries on the table.

However - this linq query fails with an Oracle Error.

var myList = dbCon.MY_TABLE.Where(x => (x.IN_SERVICE ?? true)).ToList();

It generates the SQL:

SELECT "g"."MY_COLUMN" …
FROM "OWNER"."MY_TABLE" "g"
WHERE COALESCE("g"."IN_SERVICE", N'Y') <> N'N'

I assume this does not like comparing the non-unicode column IN_SERVICE with the unicode literal N'N'.

The error is: 'ORA-12704: character set mismatch'
Is there a workaround for this that you can recommend?

Versions:

Oracle RDBMS: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0

This post has been answered by Alex Keh-Oracle on Jun 12 2023
Jump to Answer
Comments
Post Details
Added on Jun 12 2023
2 comments
423 views