I have come across an SQL statement where one of the conditions is comp_cd > to_char('0000000000','9999999999').
Running select to_char('0000000000','9999999999') from dual i am getting the result “0”.
Does anyone has come across this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The function
TO_CHARexpects a NUMBER or DATE as its first parameter, but you’re providing a string ('0000000000') instead.Therefore, Oracle uses an implicit conversion to convert it to a NUMBER first;
'0000000000'is converted to the number0.Then, TO_CHAR converts
0back to a string using the'9999999999'format model. This should result in the string:Finally:
would do a lexical (alphabetical) comparison between two strings.