Domanda

I have the following Searched Case field selection in a Oracle 10g SELECT query

(case 
    when LOADER_CELLS.CELL_MODE='RW' then 1
    when LOADER_CELLS.CELL_MODE='R' then 2
end) as CELL_EDIT_MODE_ID

but if I write it as a Simple Case expression, as follows:

(case LOADER_CELLS.CELL_MODE
    when 'RW' then 1
    when 'R' then 2
end) as CELL_EDIT_MODE_ID

I get a ORA-12704: character set mismatch error on the when 'RW' line.

I gave a look to the Oracle documentation, and it seems my syntax is correct. http://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions004.htm

Can someone help me on this?

È stato utile?

Soluzione

" I supposed that it could be a encoding problem but I don't know how to "cast" the constant strings to a NVARCHAR"

you do it with "N" syntax.

case LOADER_CELLS.CELL_MODE
    when n'RW' then 1
    when n'R' then 2
end

eg

SQL> select case a when 'a' then 1 end from foo;
select case a when 'a' then 1 end from foo
                   *
ERROR at line 1:
ORA-12704: character set mismatch


SQL> select case a when n'a' then 1 end from foo;

CASEAWHENN'A'THEN1END
---------------------
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top