0

I am making a report, and I am trying to do following: If the value of the field is NULL, output empty string. Another words, I don't need the word "null" to be output to the user, just empty string. Is that possible to write such a SQL query? How? I don't even know how to formulate a google search request for this case, so I am sorry for stupid question.

  • Search string: "oracle replace null with [whatever you feel like]" – Mat Jun 30 '14 at 8:01
-1

Use the NVL function for this.

NVL(columnName,'')

will substitute an empty string for a null value in columnName.

  • Right you are. Edited as such. – Andrew Brennan Jun 30 '14 at 11:37
  • 2
    There is practically no difference in Oracle between the empty string and the NULL value. How does this suggestion answer the question? – ypercubeᵀᴹ Jun 30 '14 at 12:46
2

In Oracle, empty string '' when assigned to a varchar2 type is NULL for all intents and purposes. In my SQLdeveloper, on a 12c database, the following query results in a (null) for every column. If you display to user a blank (a space, ' ') it would surely be displayed by all tools as a blank.

SELECT NULL, '', CAST('' as varchar2(1)), CAST('' as char(1)), NVL(null,'') FROM dual;

Why Oracle violates the SQL92 standard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.