Reputation: 59
This is the syntax I'm using when developing my SQL payload. I'm wondering why to_char is needed to perform the 1 divided by 0 operation. I read the to_char page but couldn't find an explanation. Thank you
SELECT CASE WHEN (1=2) THEN to_char(1/0) ELSE NULL END FROM dual
Upvotes: 0
Views: 638
Reputation: 1
i know about the problem he encountered, what he tried to say is when he using the 1=2 case then 1/0 wouldn't happen then the ELSE statement will trigger what he want, then he will change the statement to 1=1 to see if the 1/0 will return error but both give error no matter what case he's given. This is the query he is using:(SELECT CASE WHEN (1=1) THEN TO_CHAR((1/0)) ELSE 'a' END FROM dual) = 'a'--;
Upvotes: 0
Reputation: 143163
Why do you think that you need to_char
? In example you posted, you certainly don't:
With to_char
:
SQL> SELECT CASE WHEN (1=2) THEN to_char(1/0) ELSE NULL END result FROM dual;
R
-
Without it:
SQL> SELECT CASE WHEN (1=2) THEN 1/0 ELSE NULL END result FROM dual;
RESULT
----------
SQL>
What happens if you remove to_char
? Maybe you didn't post code you really use, because it would help us help you. This is, as you were already told, meaningless because condition is never met so Oracle doesn't even execute division by zero (which you should then handle, somehow).
So, how exactly are you "developing your SQL payload"?
Upvotes: 0
Reputation: 56
You cannot divide by zero. This causes an error. The problem is another. In your example like '(1=2)' is always false Oracle does not execute the expression 'to_char(1/0)' and always returns null.
Upvotes: 1