How does one detect whether a field is blank (not null) and then select another field if it is?
What I really need is a IsBlank function that works the same as IsNull but with with blanks.
REPLACE doesn't work with blanks, COALESCE only works with NULLS.
This isn't what the requester wanted, but is very useful to know that you can use if statements outside a select statement. EXISTS is good because it kicks out of the search loop if item is found. A COUNT runs until the end of table rows.
Inside the stored procedure, the parameter value is first tested for Null using the ISNULL function and then checked whether it is Blank (Empty). If the parameter has value then only matching records will be returned, while if the parameter is Null or Blank (Empty) then all records from the table will be returned.
No, in Oracle there is no SELECT without FROM . Using the dual table is a good practice. dual is an in-memory table. If you don't select DUMMY from it, it uses a special access path ( FAST DUAL ) which requires no I/O .
How about combining COALESCE and NULLIF.
SELECT COALESCE(NULLIF(SomeColumn,''), ReplacementColumn) FROM SomeTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With