Skip to content

How to ignore empty evaluations in string concat? #15785

You must be logged in to vote

Three ways spring to mind:

  • If predicate2 is in your control you could make it output an empty string for any input that it doesn't hold for (within reason)
  • You could make a wrapper for predicate2, like
string predicate2Wrapper(string data) {
  if predicate2(data)
  then result = predicate2(data)
  else result = ""
  }
  • You could modify your query to account for the possibility that predicate2 doesn't hold:
  from ..., string p2
  where
    ...
    and
      if predicate2(data)
      then p2 = predicate2(data)
      else p2 = ""
select predicate1(data) + p2

The way to think about it is that predicate2 doesn't hold for some values of data. In general a predicate can have multiple value…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@0x73746F70626F74686572696E676D65
Comment options

Comment options

You must be logged in to vote
1 reply
@zairulshah80
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants