1

suppose a column defined as:

col varchar2(5)
  • If col='X' is true;
  • If trim(col)=trim('X') is true;
  • But if col contains ' ', then if trim(col)=trim(' ') is false;

Why?

Thanks

1
  • Welcome to Stack Overflow. You can format source code with the Code Sample {} toolbar button—I've done it for you this time. Commented Mar 10, 2014 at 12:48

1 Answer 1

2

Oracle doesn't support empty strings like ''; Oracle uses null instead (whenever the result should be an empty string you'll get null in fact). Since

  null = null -- <- is null (and not true) 

Your formula

  trim(col) = trim(' ') -- <- equals to "null = null"

is null (and not true) too

Sign up to request clarification or add additional context in comments.

1 Comment

null = null -- <- is always false - this is definitely not true. null = null returns null. Try this: declare test boolean := null = null; begin if test is null then raise program_error; end if; end;. Yes, the idea is the same: condition will not work, but it is not false!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.