2

I am using

  • Oracle 11g
  • Devart 8.5.592
  • EntityFramework 6.1.3

The following C# code:

var testResults = _clientRepository.AsQueryable()
    .Select(c => 
        "First" + 
        (!string.IsNullOrEmpty("Second") ? ", " : "") + 
        "Third")
    .ToList();

Converts to the following SQL in Oracle:

SELECT 'First' || 
    CASE WHEN 
        CASE WHEN NOT (('Second' IS NULL) OR (6 = 0))
            THEN ', ' 
            ELSE '' END IS NULL 
        THEN N'' WHEN  NOT (('Second' IS NULL) OR (6 = 0)) 
            THEN ', ' 
            ELSE '' END || 'Third' AS C1
FROM CLI.CLE_GROUPS "Extent1"

Note: The C# code is deliberately pointless. It serves just to emphasise that it is the concatenation of strings with conditional strings that causes the problem.

This SQL when run causes the "ORA-12704: character set mismatch" exception... It is the N'' that is causing the problem. No part of the schema is using unicode.

Does anyone have any idea why it has decided to make this one empty string unicode, or even why the empty string and nested case statement are there in the first place?

aleonj
  • 163
  • 2
  • 7
  • Does it put in `6 = 0` on its own or did you omit part of the C# code? Because that would be a particularly weird thing to introduce out of the blue. I ask because for problems like these, having the exact code that reproduces something often matters. – Jeroen Mostert May 06 '16 at 16:13
  • 1
    See also http://stackoverflow.com/questions/33693374/odp-net-managed-driver-ora-12704-character-set-mismatch-in-generated-code . If it's a duplicate, this question at least boils it down to its essentials. – Jeroen Mostert May 06 '16 at 16:22
  • This type of stuff is why I don't ORM – mikey May 06 '16 at 17:24
  • 6 = 0 is random introduction, which doesn't fill one with confidence. – aleonj May 09 '16 at 07:39
  • @Jeroen Mostert: Yes, that appears to be the same issue. Thanks for locating it for me. I had actually found a different issue that also suggested interceptors (http://stackoverflow.com/questions/34645274/ef-query-to-oracle-throwing-ora-12704-character-set-mismatch) and was about to tackle that this morning. Feels like a bit of a hack, though, but also seems like I have no choice. First time in a long while that I've used an Oracle DB and now I remember why. Feel free to add your comment as an answer and I will mark it as such. – aleonj May 09 '16 at 07:42

0 Answers0