› Fóruns › SQL e PL/SQL › Decode › Decode
@Rman
Pelo que eu entendi que o seguinte, o primeiro retorno define qual tipo de dados será retornado pelo decode.
Realmente isso esta descrito na Documentação
http://docs.oracle.com/cd/B19306_01/ser … ons040.htm
“The arguments can be any of the numeric types (NUMBER, BINARY_FLOAT, or BINARY_DOUBLE) or character types.
If expr and search are character data, then Oracle compares them using nonpadded comparison semantics. expr, search, and result can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The string returned is of VARCHAR2 datatype and is in the same character set as the first result parameter.
If the first search-result pair are numeric, then Oracle compares all search-result expressions and the first expr to determine the argument with the highest numeric precedence, implicitly converts the remaining arguments to that datatype, and returns that datatype.”
Verifiquei se no primeiro par de search-result fornecer o result para char funciona o resto com char ou number, mas do contrário não, ai o result força como number e a conversão força o erro.
Procurei em alguns livros e nada, e já tinha procurado na documentação, mas não tinha lido com a devida ATENÇÃO.
valeu.