0

How to use operator like in BIRT computed column?

I tried:

if (row["Dept"] == "%desc%") { 'Test1' } else  { 'Test2' }

but it doesn't work.

And

if (row["Dept"] like "%desc%") { 'Test1' } else  { 'Test2' }

I have an error message - [Row:1, Column:28] missing ) after condition


For example in Crystal Reports I use

if {Dept} like ["*desc*", "*desc1*"] then 'Test1' else 'Test2'

But BIRT not support operator 'then'

Thanks in advance

user2943856
  • 31
  • 1
  • 1
  • 6

1 Answers1

2

LIKE is SQL syntax, whereas the expression syntax for a computed column is Javascript. But why are you using a computed column at all, when you can achieve the same result with pure SQL? E.g. with Oracle, the following SQL expression is equivalent:

case
when DEPT like '%desc%' then 'Test1'
else 'Test2'
end

OTOH if you insist on using a computed column, you could use regular expressions. See JavaScript operator similar to SQL "like"

Community
  • 1
  • 1
hvb
  • 2,484
  • 1
  • 10
  • 13